behitek / vncorenlp-wrapper

A python wrapper for VnCoreNLP
https://github.com/vncorenlp/VnCoreNLP
1 stars 0 forks source link

ImportError: cannot import name 'VNCoreNLP' #3

Closed ttran1904 closed 5 years ago

ttran1904 commented 5 years ago

I am using Python3 to run the word segmenter in VNCoreNLP. But I run into this error:

from vncorenlp import VNCoreNLP

ImportError: cannot import name 'VNCoreNLP'

I have already copied all the necessary files from VNCoreNLP (both java and python) into my work directory.

behitek commented 5 years ago

Can you run example.py file?

ttran1904 commented 5 years ago

Yex, it works perfectly fine on example.py. But when I use it in my work file, it gives me the error.

Code: ` from io import open from vncorenlp import VnCoreNLP

lst = [] # list of texts I want to scan text = [] # tokenized word list. This is for later.

vn_stop = open('vn-stop.txt', 'r').read()

vncore_nlp =VnCoreNLP(annotators="wseg pos ner parse")

for i in lst:

# tokenize document string
tokens = vncore_nlp.tokenize(i.lower(), str=False) 

# remove stop words from tokens
stopped_tokens = [i for i in tokens if not i in vn_stop]

# add tokens to list
texts.append(stopped_tokens)

`

ttran1904 commented 5 years ago

Nevermind. I think I found the typo in my code. Thank you so much :)