示例#1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     amrlib.setup_spacy_extension()
     # Load/cache spacy
     global SPACY_NLP
     if SPACY_NLP is None:
         SPACY_NLP = spacy.load('en_core_web_sm')
     self.nlp = SPACY_NLP
     # Load model in amrlib (amrlib will cache this itself)
     global T5V2_LOADED
     if T5V2_LOADED is None:
         print('Loading', self.model_dir)
         amrlib.load_stog_model(model_dir=self.model_dir)
         T5V2_LOADED = True
     self.stog = amrlib.stog_model
#!/usr/bin/python3
import setup_run_dir  # run script 2 levels up

# basic spacy extension example code
import amrlib
import spacy
amrlib.setup_spacy_extension()
nlp = spacy.load('en_core_web_sm')
doc = nlp(
    'This is a test of the SpaCy extension. The test has multiple sentences.')
graphs = doc._.to_amr()
for graph in graphs:
    print(graph)
示例#3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     amrlib.setup_spacy_extension()
     self.nlp = SPACY_NLP