Questions tagged [nltk-book]
48 questions
1
vote
1 answer
POS Tagger for a Virtual Assistant
I'm trying to build a POS Tagger for a Voise Assistant. However, the nltk's pos tagger nltk.pos_tag doesn't work well for me. For example:
sent = 'open Youtube'
tokens = nltk.word_tokenize(sent)
nltk.pos_tag(tokens, tagset='universal')
>>[('open',…

Mohit Motwani
- 4,662
- 3
- 17
- 45
1
vote
2 answers
Python, NLTK: NameError: name 'load_parser' is not defined
I'm trying to run this example provided from NLTK book here:
>>> from nltk import load_parser
>>> cp = load_parser('grammars/book_grammars/sql0.fcfg')
>>> query = 'What cities are located in China'
>>> trees = list(cp.parse(query.split()))
>>>…

Alaa
- 19
- 1
- 4
0
votes
0 answers
NLTK - explanation of inconsistent behavior of disperson_plot
Why ahab and Ahab make the difference in nltk dispersion_plot?
from nltk.book import (
text1 as mobydick
)
mobydick.dispersion_plot(['starbuck', 'captain', 'ahab'])
mobydick.dispersion_plot(['starbuck', 'captain', 'Ahab'])
Environment
NLTK:…

mon
- 18,789
- 22
- 112
- 205
0
votes
1 answer
Lexical dispersion plot with nltk is not working right
i have been using a nltk code to make a lexical dispersion plot. As you can see in the code below ( please excuse the messy imports). I took text for 4 local pdfs extracted the text and did the word_tokenize bit. I have also done the other option…

Kenneth Gomes
- 11
- 2
0
votes
0 answers
nltk.download not working showing errorno 11001 getaddrinfo failed and
When I run interactive installation as per the guide of nltk, i.e
import nltk
nltk.download()
enter image description here
so as these error occurred I start installing it via proxy server
>>> nltk.set_proxy('http://proxy.example.com:3128',…

Saif Rahman
- 1
- 1
0
votes
0 answers
NLTK, Prover9: DiscourseTester fails at informativity check (informchk)
I am currently working with the DiscourseTester implemented in NLTK. I have the recent version of NLTK (3.8.1) and work with Python 3.8. The DiscourseTester fails when I set the informchk=True, but works if it is set to False.
Does anyone know what…

Tania
- 1
- 2
0
votes
0 answers
NLTK download error (Host not responding)
this is the image (on the bottom u can find the error)
nltk.download()
after this command the above dialog box appeared but once i click download it says host not responding
Error downloading •abc' from <…

David Franklin
- 1
- 1
0
votes
1 answer
NLTK available languages for word tokenization and sentence tokenization
I need to understand for which languages the tokenization in NLTK is possible. I think I need to set the language like this:
import nltk.data
lang = "WHATEVER_LANGUAGE"
tokenizer = nltk.data.load('nltk:tokenizers/punkt/'+lang+'.pickle')
text =…

Simona Lo Giudice
- 61
- 1
- 3
0
votes
1 answer
Total Frequency Count for words using NLTK Python
While testing a standard way of written code to count the total frequency of words in a sentence (counting number of times the same word appears), using the NLTK with Python, i am getting no result, the program does not output a result. it seems…

Calculate
- 329
- 1
- 5
- 19
0
votes
1 answer
Getting sense stems for nltk semcor corpus words
I was trying semcor corpus in nltk.
I found this code here:
>>> list(map(str, semcor.tagged_chunks(tag='both')[:3]))
['(DT The)', "(Lemma('group.n.01.group') (NE (NNP Fulton County Grand Jury)))", "(Lemma('state.v.01.say') (VB said))"]
I tried the…

Mahesha999
- 22,693
- 29
- 116
- 189
0
votes
1 answer
Obtaining METEOR scores for Japanese text
I wish to produce METEOR scores for several Japanese strings. I have imported nltk, wordnet and omw but the results do not convince me it is working correctly.
from nltk.corpus import wordnet
from nltk.translate.meteor_score import…

phil
- 1,938
- 4
- 23
- 33
0
votes
1 answer
How to get consolidated words post tagging?
I am working on a dataset that requires extracting all the words that are adjectives, verbs, and adverbs from each sentence of a data frame column.
This is a sample I was working on to figure out how I could get the desired…

Dynamo
- 51
- 8
0
votes
1 answer
Using nltk.book import in a function
I am trying to write a simple function as follows:
def lexical_diversity(text,word):
from nltk.book import text
return 100*text.count(word)/len(set(text))
I understand that I can import a text before the function. But, I was wondering why I…

Navid Asgari
- 21
- 4
0
votes
1 answer
How to take output of nltk.book, common_contexts function to a variable
common_contexts in nltk.book returns NoneType and hence how is it possible to store its output to a variable
from nltk.book import *
wtc=text1.common_contexts(['you'])
print(wtc)
print(type(wtc))
wtc variable above will return NONE.

sakeesh
- 919
- 1
- 10
- 24
0
votes
1 answer
Words in WordNet corpus clarification
I want to get the length of words in the WordNet corpus
Code:
from nltk.corpus import wordnet as wn
len_wn = len([word.lower() for word in wn.words()])
print(len_wn)
I get the output as 147306
My Questions:
Am I getting the total length of words…

floss
- 2,603
- 2
- 20
- 37