Skip to content

Commit

Permalink
added modal and verb to json
Browse files Browse the repository at this point in the history
  • Loading branch information
rangat committed Mar 3, 2019
1 parent c700aba commit 0f1859f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions funk.py
Expand Up @@ -172,6 +172,11 @@ def punct_in_set(pos_set:list):
return True
return False

def get_pos_word_in_set(word_set:list, pos:str):
for tup in word_set:
if tup[1][0].lower() == pos.lower():
return tup[0]
return None

# from nltk import word_tokenize
# from nltk import pos_tag
Expand Down
8 changes: 8 additions & 0 deletions tag_JSON.py
Expand Up @@ -23,6 +23,8 @@ def tagList(jsonList:list, whWord:str, collocate:str, context:str):
tagged = pos_tag(word_tokenize(sent))

clauseType = None
modal = None
verb = None

modals = ['can', 'could', 'may', 'might', 'shall', 'should', 'will', 'would', 'must']

Expand Down Expand Up @@ -53,15 +55,19 @@ def tagList(jsonList:list, whWord:str, collocate:str, context:str):
# ELSE IF "to" exists in SET B - Non-Finite
elif f.x_in_set("to", wh_collocate, is_pos=False):
clauseType = "Non-Finite"
verb = f.get_pos_word_in_set(wh_collocate, 'V')
# ELSE IF "gap" exists in either set - :
elif f.x_in_set(":", context_wh, is_pos=True) or f.x_in_set(":", wh_collocate, is_pos=True):
clauseType = ":"
# ELSE IF modal exists in SET B - Modal
elif f.x_in_set(modals, wh_collocate, is_pos=False):
clauseType = "Modal"
modal = f.get_pos_word_in_set(wh_collocate, 'M')
verb = f.get_pos_word_in_set(wh_collocate, 'V')
# ELSE - Finite
else:
clauseType = "Finite"
verb = f.get_pos_word_in_set(wh_collocate, 'V')
except:
print("BROKE HERE: ")
print(obj["resNumber"])
Expand All @@ -71,5 +77,7 @@ def tagList(jsonList:list, whWord:str, collocate:str, context:str):
break

obj['clauseType'] = clauseType
obj['modal'] = modal
obj['verb'] = verb

return jsonList

0 comments on commit 0f1859f

Please sign in to comment.