def func(nlp): if nlp.meta['name'] in excluded_nlps: return doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) assert rules_analyzer.is_independent_noun(doc[referred_index]) or \ rules_analyzer.is_potential_anaphor(doc[referred_index]) assert rules_analyzer.is_potential_anaphor(doc[referring_index]) referred_mention = Mention(doc[referred_index], include_dependent_siblings) self.assertEqual( expected_truth, rules_analyzer.is_potential_anaphoric_pair( referred_mention, doc[referring_index], True), nlp.meta['name']) self.assertEqual( expected_reflexive_truth, rules_analyzer.is_potential_reflexive_pair( referred_mention, doc[referring_index]), nlp.meta['name']) self.assertEqual( is_reflexive_anaphor_truth, rules_analyzer.is_reflexive_anaphor(doc[referring_index]), nlp.meta['name'])
def func(nlp): doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) self.assertEqual( expected_dependent_siblings, str(doc[index]._.coref_chains.temp_dependent_siblings), nlp.meta['name']) for sibling in (sibling for sibling in doc[index]._.coref_chains.temp_dependent_siblings if sibling.i != index): self.assertEqual(doc[index], sibling._.coref_chains.temp_governing_sibling, nlp.meta['name']) if expected_governing_sibling is None: self.assertEqual( None, doc[index]._.coref_chains.temp_governing_sibling, nlp.meta['name']) else: self.assertEqual( doc[expected_governing_sibling], doc[index]._.coref_chains.temp_governing_sibling, nlp.meta['name']) self.assertEqual( expected_has_or_coordination, doc[index]._.coref_chains.temp_has_or_coordination, nlp.meta['name'])
def func(nlp): if nlp.meta['name'] in excluded_nlps: return doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) self.assertEqual(expected_truth, rules_analyzer.is_potentially_referring_back_noun(doc[index]), nlp.meta['name'])
def func(nlp): if nlp.meta['name'] in excluded_nlps: return doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) per_indexes = [token.i for token in doc if rules_analyzer.is_independent_noun(token)] self.assertEqual(expected_per_indexes, per_indexes, nlp.meta['name'])
def func(nlp): doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) ancestor = rules_analyzer.get_ancestor_spanning_any_preposition( doc[index]) if ancestor is None: self.assertEqual(expected_index, None) else: self.assertEqual(expected_index, ancestor.i)
def func(nlp): if nlp.meta['name'] in excluded_nlps: return doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) assert rules_analyzer.is_independent_noun(doc[referred_index]) or \ rules_analyzer.is_potential_anaphor(doc[referred_index]) assert rules_analyzer.is_potential_anaphor(doc[referring_index]) referred_mention = Mention(doc[referred_index], include_dependent_siblings) if consider_syntax: self.assertEqual(expected_truth, rules_analyzer.language_independent_is_potential_anaphoric_pair( referred_mention, doc[referring_index]), nlp.meta['name']) else: self.assertEqual(expected_truth, rules_analyzer.is_potential_anaphoric_pair( referred_mention, doc[referring_index], False), nlp.meta['name'])
def func(nlp): if nlp.meta['name'] in excluded_nlps: return doc = nlp(doc_text) rules_analyzer = RulesAnalyzerFactory.get_rules_analyzer(nlp) rules_analyzer.initialize(doc) if expected_potential_referreds is None: self.assertFalse( hasattr(doc[index]._.coref_chains, 'temp_potential_referreds')) else: potential_referreds = [ referred.pretty_representation for referred in doc[index]._.coref_chains.temp_potential_referreds ] self.assertEqual(expected_potential_referreds, potential_referreds, nlp.meta['name'])
def setUp(self): self.nlps = get_nlps('en') self.rules_analyzers = [ RulesAnalyzerFactory.get_rules_analyzer(nlp) for nlp in self.nlps ]