From e857922ee561c3432abe8175e650b1e137c2c158 Mon Sep 17 00:00:00 2001 From: Titas Date: Mon, 4 May 2020 10:46:06 +0530 Subject: [PATCH 1/5] Fix --- Giveme5W1H/extractor/extractors/cause_extractor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Giveme5W1H/extractor/extractors/cause_extractor.py b/Giveme5W1H/extractor/extractors/cause_extractor.py index 8c446f36..18df6265 100644 --- a/Giveme5W1H/extractor/extractors/cause_extractor.py +++ b/Giveme5W1H/extractor/extractors/cause_extractor.py @@ -4,6 +4,7 @@ import nltk from nltk.corpus import wordnet from nltk.stem.wordnet import WordNetLemmatizer +from nltk import Tree, ProbabilisticTree from Giveme5W1H.extractor.candidate import Candidate from Giveme5W1H.extractor.extractors.abs_extractor import AbsExtractor @@ -127,8 +128,9 @@ def _evaluate_tree(self, tree): while sibling.label() == 'ADVP' and sibling.right_sibling() is not None: sibling = sibling.right_sibling() - # NP-VP-NP pattern found .unicode_repr() - if sibling.label() == 'VP' and "('NP'" in sibling.unicode_repr(): + # NP-VP-NP pattern found .__repr__() + + if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): verbs = [t[0] for t in sibling.pos() if t[1][0] == 'V'][:3] verb_synset = set() From 875a61b3ad25dac7317105120ff0fce50b14a930 Mon Sep 17 00:00:00 2001 From: Titas Date: Mon, 4 May 2020 11:06:21 +0530 Subject: [PATCH 2/5] Fix --- Giveme5W1H/extractor/extractors/cause_extractor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Giveme5W1H/extractor/extractors/cause_extractor.py b/Giveme5W1H/extractor/extractors/cause_extractor.py index 18df6265..c3449805 100644 --- a/Giveme5W1H/extractor/extractors/cause_extractor.py +++ b/Giveme5W1H/extractor/extractors/cause_extractor.py @@ -4,7 +4,7 @@ import nltk from nltk.corpus import wordnet from nltk.stem.wordnet import WordNetLemmatizer -from nltk import Tree, ProbabilisticTree + from Giveme5W1H.extractor.candidate import Candidate from Giveme5W1H.extractor.extractors.abs_extractor import AbsExtractor @@ -129,8 +129,7 @@ def _evaluate_tree(self, tree): sibling = sibling.right_sibling() # NP-VP-NP pattern found .__repr__() - - if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): + if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): verbs = [t[0] for t in sibling.pos() if t[1][0] == 'V'][:3] verb_synset = set() From f1dca370578a461199caf7b9faa0e87ccd9281d8 Mon Sep 17 00:00:00 2001 From: Titas Date: Mon, 4 May 2020 11:10:40 +0530 Subject: [PATCH 3/5] Fix --- Giveme5W1H/extractor/extractors/cause_extractor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Giveme5W1H/extractor/extractors/cause_extractor.py b/Giveme5W1H/extractor/extractors/cause_extractor.py index c3449805..ed1a1d00 100644 --- a/Giveme5W1H/extractor/extractors/cause_extractor.py +++ b/Giveme5W1H/extractor/extractors/cause_extractor.py @@ -5,7 +5,6 @@ from nltk.corpus import wordnet from nltk.stem.wordnet import WordNetLemmatizer - from Giveme5W1H.extractor.candidate import Candidate from Giveme5W1H.extractor.extractors.abs_extractor import AbsExtractor From cc419e743ad21d299e2553dd8f025f72bc08eb87 Mon Sep 17 00:00:00 2001 From: Titas Date: Mon, 4 May 2020 11:10:40 +0530 Subject: [PATCH 4/5] Fix for issue #47 with correct indentation --- Giveme5W1H/extractor/extractors/cause_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Giveme5W1H/extractor/extractors/cause_extractor.py b/Giveme5W1H/extractor/extractors/cause_extractor.py index ed1a1d00..88e081a1 100644 --- a/Giveme5W1H/extractor/extractors/cause_extractor.py +++ b/Giveme5W1H/extractor/extractors/cause_extractor.py @@ -128,7 +128,7 @@ def _evaluate_tree(self, tree): sibling = sibling.right_sibling() # NP-VP-NP pattern found .__repr__() - if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): + if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): verbs = [t[0] for t in sibling.pos() if t[1][0] == 'V'][:3] verb_synset = set() From d1b6a2c97cf01ebcf737556839bf4ffc276d7617 Mon Sep 17 00:00:00 2001 From: Titas Date: Thu, 14 May 2020 22:14:24 +0530 Subject: [PATCH 5/5] Fixed Indentation --- Giveme5W1H/extractor/extractors/cause_extractor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Giveme5W1H/extractor/extractors/cause_extractor.py b/Giveme5W1H/extractor/extractors/cause_extractor.py index 88e081a1..4c9f95f8 100644 --- a/Giveme5W1H/extractor/extractors/cause_extractor.py +++ b/Giveme5W1H/extractor/extractors/cause_extractor.py @@ -128,7 +128,7 @@ def _evaluate_tree(self, tree): sibling = sibling.right_sibling() # NP-VP-NP pattern found .__repr__() - if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): + if sibling.label() == 'VP' and "('NP'" in sibling.__repr__(): verbs = [t[0] for t in sibling.pos() if t[1][0] == 'V'][:3] verb_synset = set() @@ -214,8 +214,9 @@ def _evaluate_tree(self, tree): # If we come along an adverb (RB) check the adverbials that indicate causation candidates.append(deepcopy([pos[:i], pos[i - 1:], 'RB'])) - elif token in self.causal_conjunctions and ' '.join([x['nlpToken']['originalText'] for x in tokens[i:]]).lower().startswith( - self.causal_conjunctions[token]): + elif token in self.causal_conjunctions and ' '.join( + [x['nlpToken']['originalText'] for x in tokens[i:]]).lower().startswith( + self.causal_conjunctions[token]): # Check if token is a clausal conjunction indicating causation start = i if token not in self.causal_conjunctions_inclusive: @@ -276,7 +277,7 @@ def _evaluate_candidates(self, document): elif candidateObject.get_type() == 'RB': # while not as significant as biclausal indicators, adverbials are mor significant as the verbs score += self.weights[2] - else: # NP-VP-NP + else: # NP-VP-NP score += self.weights[3] if score > 0: