Skip to content

Commit

Permalink
add pattern matching 2
Browse files Browse the repository at this point in the history
  • Loading branch information
elizajasin committed Jun 15, 2017
1 parent 36b68f2 commit 19a8964
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
34 changes: 17 additions & 17 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions PatternMatching.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__author__ = 'elizajasin'

import ReadAndWriteFile as RAWfile
from openpyxl import Workbook
import re

# Read Data
Expand All @@ -9,19 +10,23 @@
# Matching Words
classes = []
for i in range(len(hadits)):
match1 = re.search(r'jangan', hadits[i])
match2 = re.search(r'larang', hadits[i])
match3 = re.search(r'lah', hadits[i])
match1 = re.search(r'jangan|larang', hadits[i])
match2 = re.search(r'hendaklah|lakukanlah|berdirilah|shalatlah|pergilah|berwudhulah', hadits[i])

if match1:
classes.append(3)
elif match2:
classes.append(3)
elif match3:
classes.append(2)
else:
classes.append(1)

# Write Classes Result
wb = Workbook()
ws = wb.active
for i in range(len(classes)):
ws.cell(row=i+1, column=1).value = classes[i]
wb.save('result_pattern_matching.xlsx')

# Read Target Classes
target = RAWfile.readDataClass('hadits_dist_172.xlsx')

Expand Down
Binary file added result_pattern_matching.xlsx
Binary file not shown.

0 comments on commit 19a8964

Please sign in to comment.