elitcloud / elit

🔠 Evolution of Language and Information Technology
https://elit.cloud
Other
47 stars 7 forks source link

AttributeError: 'NoneType' object has no attribute '_vocab' #36

Closed Jeevi10 closed 4 years ago

Jeevi10 commented 4 years ago

I installed and ran below code from elit.structure import Document, Sentence, TOK, POS from elit.component import SDPBiaffineParser

tokens = ['John', 'who', 'I', 'wanted', 'to', 'meet', 'was', 'smart'] postags = ['NNP', 'IN', 'WP', 'PRP', 'VBD', 'DT', 'NN', 'VBD', 'JJ'] doc = Document() doc.add_sentence(Sentence({TOK: tokens, POS: postags}))

print(doc)

sdp = SDPBiaffineParser() sdp.decode(doc) print(doc.sentences[0])

and it throws error as shown below.

AttributeError Traceback (most recent call last) in 8 #print(doc) 9 sdp = SDPBiaffineParser() ---> 10 sdp.decode(doc) 11 print(doc.sentences[0])

~/anaconda3/lib/python3.7/site-packages/elit/component/sdp/sdp_parser.py in decode(self, docs, num_buckets_test, test_batch_size, **kwargs) 119 :return: docs 120 """ --> 121 vocab = self._parser._vocab 122 for d in docs: 123 for s in d:

AttributeError: 'NoneType' object has no attribute '_vocab'

hankcs commented 4 years ago

Need to load model before use it, i.e. sdp.load()

Jeevi10 commented 4 years ago

Need to load model before use it, i.e. sdp.load()

Thanks it worked. I appreciate your time.