nlp

nlpnet POSTagger returns error message when allow_pickle=False

血红的双手。 提交于 2021-02-10 14:35:26
问题 I have installed the latest version of nlpnet library (http://nilc.icmc.usp.br/nlpnet/). Then, when I try to use nlpnet POSTagger according to the follwoing example, I get an error: import nlpnet tagger = nlpnet.POSTagger('/path/to/pos-model/', language='pt') Error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/r/env2/lib/python3.6/site-packages/nlpnet/taggers.py", line 205, in __init__ self._load_data() File "/home/r/env2/lib/python3.6/site-packages

Error converting Pegasus to the ONNX format from Transformers

◇◆丶佛笑我妖孽 提交于 2021-02-10 14:21:55
问题 I am trying to convert the Pegasus newsroom in HuggingFace's transformers model to the ONNX format. I followed this guide published by Huggingface. After installing the prereqs, I ran this code: !rm -rf onnx/ from pathlib import Path from transformers.convert_graph_to_onnx import convert convert(framework="pt", model="google/pegasus-newsroom", output=Path("onnx/google/pegasus-newsroom.onnx"), opset=11) and got these errors: ValueError Traceback (most recent call last) <ipython-input-9

Ntlk & Python, plotting ROC curve

时光怂恿深爱的人放手 提交于 2021-02-10 13:29:13
问题 I am using nltk with Python and I would like to plot the ROC curve of my classifier (Naive Bayes). Is there any function for plotting it or should I have to track the True Positive rate and False Positive rate ? It would be great if someone would point me to some code already doing it... Thanks. 回答1: PyROC looks simple enough: tutorial, source code This is how it would work with the NLTK naive bayes classifier: # class labels are 0 and 1 labeled_data = [ (1, featureset_1), (0, featureset_2),

Word2vec - get rank of similarity

跟風遠走 提交于 2021-02-10 12:58:41
问题 Given I got a word2vec model (by gensim), I want to get the rank similarity between to words. For example, let's say I have the word "desk" and the most similar words to "desk" are: table 0.64 chair 0.61 book 0.59 pencil 0.52 I want to create a function such that: f(desk,book) = 3 Since book is the 3rd most similar word to desk. Does it exists? what is the most efficient way to do this? 回答1: You can use the rank(entity1, entity2) to get the distance - same as the index. model.wv.rank(sample

Word2vec - get rank of similarity

心不动则不痛 提交于 2021-02-10 12:57:05
问题 Given I got a word2vec model (by gensim), I want to get the rank similarity between to words. For example, let's say I have the word "desk" and the most similar words to "desk" are: table 0.64 chair 0.61 book 0.59 pencil 0.52 I want to create a function such that: f(desk,book) = 3 Since book is the 3rd most similar word to desk. Does it exists? what is the most efficient way to do this? 回答1: You can use the rank(entity1, entity2) to get the distance - same as the index. model.wv.rank(sample

when training data using IBM Bluemix natural language classifier api, return data too small

天涯浪子 提交于 2021-02-10 12:47:57
问题 When I follow "Getting started with the Natural Language Classifier service" guide line, I meet problem at Stage 2: Create and train a classifier: $ curl -i -u "<username>":"<password>" \ -F training_data=@<path_to_file>/weather_data_train.csv \ -F training_metadata="{\"language\":\"en\",\"name\":\"TutorialClassifier\"}" \ "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers" It returns: { "code" : 400, "error" : "Data too small", "description" : "The number of

Pip install error exit status 1 while installing a pip package

醉酒当歌 提交于 2021-02-10 11:52:48
问题 I'm having an issue while trying to install the pyresparser python library. The issue seems to be regarding a Spacy library. How could I solve this and install successfully ? I am a rookie on python C:\Users\User>pip install pyresparser Collecting pyresparser Using cached https://files.pythonhosted.org/packages/ad/8f/5a55cfb269621d3374a6ba4aed390267f65bdf6c4fed8b1c0cbf5a118f0e/pyresparser-1.0.2-py3-none-any.whl Collecting idna>=2.8 (from pyresparser) Downloading https://files.pythonhosted.org

Pip install error exit status 1 while installing a pip package

有些话、适合烂在心里 提交于 2021-02-10 11:52:07
问题 I'm having an issue while trying to install the pyresparser python library. The issue seems to be regarding a Spacy library. How could I solve this and install successfully ? I am a rookie on python C:\Users\User>pip install pyresparser Collecting pyresparser Using cached https://files.pythonhosted.org/packages/ad/8f/5a55cfb269621d3374a6ba4aed390267f65bdf6c4fed8b1c0cbf5a118f0e/pyresparser-1.0.2-py3-none-any.whl Collecting idna>=2.8 (from pyresparser) Downloading https://files.pythonhosted.org

Pip install error exit status 1 while installing a pip package

好久不见. 提交于 2021-02-10 11:51:06
问题 I'm having an issue while trying to install the pyresparser python library. The issue seems to be regarding a Spacy library. How could I solve this and install successfully ? I am a rookie on python C:\Users\User>pip install pyresparser Collecting pyresparser Using cached https://files.pythonhosted.org/packages/ad/8f/5a55cfb269621d3374a6ba4aed390267f65bdf6c4fed8b1c0cbf5a118f0e/pyresparser-1.0.2-py3-none-any.whl Collecting idna>=2.8 (from pyresparser) Downloading https://files.pythonhosted.org

FastText recall is 'nan' but precision is a number

旧时模样 提交于 2021-02-10 05:31:20
问题 I trained a supervised model in FastText using the Python interface and I'm getting weird results for precision and recall. First, I trained a model: model = fasttext.train_supervised("train.txt", wordNgrams=3, epoch=100, pretrainedVectors=pretrained_model) Then I get results for the test data: def print_results(N, p, r): print("N\t" + str(N)) print("P@{}\t{:.3f}".format(1, p)) print("R@{}\t{:.3f}".format(1, r)) print_results(*model.test('test.txt')) But the results are always odd, because