-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
| results = [firstToken] |
When the text,
the dog and other animals are nice.
is fed to the knowledge graph pipeline, the relation animals-dog and animals-are are extracted. The latter is not a hyponym-hypernym pair, and this can be prevented with some modifcations to getRelations in and_other_pattern_matcher.py:
def getRelations(self, doc: Doc) -> [Relation]:
relations = []
matches = self._matcher(doc)
for match_id, start, end in matches:
span = doc[start:end]
hypernym = span.text.split()[-1]
firstToken = span.root
# get all hyponyms
results = [firstToken]
while firstToken and firstToken.head.pos_ == "NOUN":
results.append(firstToken.head)
firstToken = firstToken.head
# make relations
for result in results:
relations.append(Relation(hypernym, result.text))
return relationsMetadata
Metadata
Assignees
Labels
No labels