@@ -281,7 +281,7 @@ As we can see, the frame detector makes a distinction in sentence 1 between two
281281Similarly, in sentence 2 the frame detector finds a light verb construction in which 'have' is the light verb and
282282'look' is a frame evoking word.
283283
284- ### Tagging a List of Sentences
284+ ## Tagging a List of Sentences
285285
286286Often, you may want to tag an entire text corpus. In this case, you need to split the corpus into sentences and pass a
287287list of ` Sentence ` objects to the ` .predict() ` method.
@@ -361,6 +361,44 @@ are provided:
361361| 'communicative-functions' | English | detecting function of sentence in research paper (BETA) | scholarly papers | |
362362| 'de-offensive-language' | German | detecting offensive language | [ GermEval 2018 Task 1] ( https://projects.fzai.h-da.de/iggsa/projekt/ ) | ** 75.71** (Macro F1) |
363363
364+
365+ ## Experimental: Relation Extraction
366+
367+ Relations hold between two entities. For instance, a text like "George was born in Washington"
368+ names two entities and also expresses that there is a born_in relationship between
369+ both.
370+
371+ We added two experimental relation extraction models,
372+ trained over a modified version of TACRED: ` relations ` and ` relations-fast ` .
373+ Use these models together with an entity tagger, like so:
374+ ``` python
375+ from flair.data import Sentence
376+ from flair.models import RelationExtractor, SequenceTagger
377+
378+ # 1. make example sentence
379+ sentence = Sentence(" George was born in Washington" )
380+
381+ # 2. load entity tagger and predict entities
382+ tagger = SequenceTagger.load(' ner-fast' )
383+ tagger.predict(sentence)
384+
385+ # check which entities have been found in the sentence
386+ entities = sentence.get_labels(' ner' )
387+ for entity in entities:
388+ print (entity)
389+
390+ # 3. load relation extractor
391+ extractor: RelationExtractor = RelationExtractor.load(' relations-fast' )
392+
393+ # predict relations
394+ extractor.predict(sentence)
395+
396+ # check which relations have been found
397+ relations = sentence.get_labels(' relation' )
398+ for relation in relations:
399+ print (relation)
400+ ```
401+
364402## Tagging new classes without training data
365403
366404In case you need to label classes that are not included you can also try
0 commit comments