You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a corpus that contains brief one paragraph bios from thousands of people. I'm hoping to extract more granular relations from it. For instance, with the text "Tim Cook is the president and CEO of Apple", the relation output is "Tim Cook -> Apple" → employee_of and "Apple -> Tim Cook" → works_for (0.9953). I want this to extract "Tim Cook -> Apple" → president and CEO. I understand I can hand label this sentence (and others) and train an additional layer, but I'm wondering if there's another (hopefully less manual) way to extract the relation. Thanks!
from flair.nn import Classifier
from flair.data import Sentence
text = "Tim Cook is the president and CEO of Apple"
# load the model
tagger = Classifier.load('ner')
# make a sentence
sentence = Sentence(text)
# predict NER tags
tagger.predict(sentence)
# load relation extractor
extractor = Classifier.load('relations')
# predict relations
extractor.predict(sentence)
# check which relations have been found
relations = sentence.get_labels('relation')
for relation in relations:
print(relation)
Hello @hyshandler, I think an OpenIE model could do what you are looking for. We don't currently have one in Flair, but we are building one that will likely be added in a future release.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Question
I have a corpus that contains brief one paragraph bios from thousands of people. I'm hoping to extract more granular relations from it. For instance, with the text "Tim Cook is the president and CEO of Apple", the relation output is "Tim Cook -> Apple" → employee_of and "Apple -> Tim Cook" → works_for (0.9953). I want this to extract "Tim Cook -> Apple" → president and CEO. I understand I can hand label this sentence (and others) and train an additional layer, but I'm wondering if there's another (hopefully less manual) way to extract the relation. Thanks!
Relation[0:2][6:7]: "Tim Cook -> Apple" → employee_of (1.0)
Relation[6:7][0:2]: "Apple -> Tim Cook" → works_for (0.9953)
The text was updated successfully, but these errors were encountered: