Skip to content

Commit

Permalink
Fix bug that any codeword was returned in the the list of tags in con…
Browse files Browse the repository at this point in the history
…dition. This search should happen ONLY in the condition so now passing condition (not sentence) to get_regex_code_elem
  • Loading branch information
snadi committed Oct 7, 2019
1 parent 917de3e commit 4071a44
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/corenlp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def build_cond_sentence(sentence):
condition = get_condition_from_sentence(sentence)
cond_sentence.set_condition(condition)
cond_sentence.set_nfreqs(get_non_func(condition))
nouns_in_cond = list(set(get_nouns(sentence, condition) + get_regex_code_elem(sentence_text)))
nouns_in_cond = list(set(get_nouns(sentence, condition) + get_regex_code_elem(condition)))
cond_sentence.set_nouns(nouns_in_cond)

#set the value for all the factors/features we check for
Expand Down Expand Up @@ -285,7 +285,6 @@ def build_cond_sentence(sentence):

return None

## @Christoph: this is where you would want to play with things
def get_cond_sentences_from_para(paragraph, q_id, answ_id, parag_index):
cond_sentences = list()
annotations = corenlp.annotate(paragraph, corenlp_properties)
Expand Down Expand Up @@ -347,10 +346,12 @@ def get_non_func(string):

def get_regex_code_elem(sentence_text):
result = []
for pattern in REGEX_LIST:
for word in sentence_text.split():
if re.match(pattern, word):
result.append(word)

if sentence_text is not None:
for pattern in REGEX_LIST:
for word in sentence_text.split():
if re.match(pattern, word):
result.append(word)

return result

Expand Down

0 comments on commit 4071a44

Please sign in to comment.