Exemplo n.º 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
Exemplo n.º 2
0
 def testStoG(self):
     stog = amrlib.load_stog_model()
     graphs = stog.parse_sents(['This is a test of the system.'])
     self.assertEqual(len(graphs), 1)
Exemplo n.º 3
0
#!/usr/bin/python3
import setup_run_dir  # run script 2 levels up

# Basic parse / generate example code
import amrlib

print('Example parsing')
stog = amrlib.load_stog_model()
graphs = stog.parse_sents(
    ['This is a test of the system.', 'This is a second sentence.'])
for graph in graphs:
    print(graph)
    print()

print('Generation Example - loading model')
gtos = amrlib.load_gtos_model()
sents, _ = gtos.generate(graphs)
for sent in sents:
    print(sent)