Questions tagged [nltk-book]

48 questions
0
votes
1 answer

Regular expression to match characters inside a word

I am doing the Pig Latin text conversion: One of the requirements is putting qu together. What I did re.findall(r'^qu', token) but it only accepts qu together if the word/token starts with qu If the word/token starts with aqu then it does not…
floss
  • 2,603
  • 2
  • 20
  • 37
0
votes
1 answer

how to calculate Word Coverage in gutenburg corpus in python library nltk?

Compute the word coverage of all file IDs associated with the text corpus gutenberg. what is the write code for this, import nltk from nltk.corpus import gutenburg from decimal import Decimal for fileid in gutenburg.fileids(): n_chars =…
0
votes
2 answers

Python - printing out a trie in alphabetically sorted order with a recursive function

I'm working my way through the NLTK book by Bird, Klein, and Loper and I'm stuck on a problem. I'm working through the book for my own personal enrichment, and not for a class. The problem I'm stuck on is 4.29: Write a recursive function that…
0
votes
1 answer

Setting path for macecommand for nltk

I found a solution to set the path for prover9 from the link config_prover9 method for setting prover9 path Is there any similar method for dealing with macecommand too? My code is below a4 = read_expr('exists y. (woman(y) & all x. (man(x)…
0
votes
1 answer

Python : AttributeError: 'NoneType' object has no attribute 'start'

The below code belongs to NLTK regex: import nltk nltk.download('punkt') from nltk.tokenize import word_tokenize from nltk.tokenize import sent_tokenize scene = "Hello how! how are you? what is your problem. Can I solve with 00code for you/ by the…
jain
  • 113
  • 2
  • 12
0
votes
1 answer

nltk dispersion_plot() function not working. Has the line-style "|" been removed from matplotlib?

I am trying to draw lexical dispersion plots using nltk dispersion_plot() function. My code is from nltk.book import * text4.dispersion_plot(["freedom","citizens"]) The resulting plot I get is ]1) After doing some google search and going through…
0
votes
0 answers

Receiving error messages while importing nltk

I was successfully able to install nltk and I have all the prerequisites installed as well. Nonetheless I have been receiving error messages like these while importing nltk. >>> import nltk Traceback (most recent call last): File "", line…
Saurav Saha
  • 745
  • 1
  • 11
  • 30
0
votes
1 answer

nltk pos_tag error in windows Anaconda

while I wish to collect POS tags using pos_tag function the following error occurs.i included all packages required for nltk. nltk version is 3.3 and running in conda environment . python version is 3.6. every nltk packages are downloaded using nltk…
nikki
  • 375
  • 2
  • 4
  • 13
0
votes
1 answer

NLTK pos tagger is creating different tags for the same word. Can anybody explain this?

The word RR is tagged as NN in one case and NNP in another. Also applicant is tagged as NN in one case and JJ in another. Why is this difference on the same word ? Shouldn't anything starting with a capital letter be tagged as NNP ? testb Out[45]:…
Palash Jhamb
  • 605
  • 6
  • 15
0
votes
0 answers

Setting up nltk data from github repo

I was following nltk book chapter 1. I am able to install nltk (import nltk) but was not able to download the book corpus by running nltk.download(). It gave me getattrinfo failed error. So I started quickly going through commands in chapter without…
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
0
votes
1 answer

How to find NLTK missing resource?

I am new to python programming and my objective is to learn to use nltk book collection. But unfortunately I am unable to use any functions and it shows a lookup error with a suggestion to use the function nltk.download('genesis'). But I couldn't…
0
votes
0 answers

ntlk TypeError: expected string or bytes-like

When I tried to use sent_tokenize from nltk package, I have TypeError: expected string or bytes-like object Here is my code: import ntlk from ntlk.book import * from ntlk.tokenize import sent_tokenize print(sent_tokenize(text9)) Can you help…
0
votes
2 answers

Dictionary not sorting correctly in python

My code should output the top 10 words with the highest frequency in the corpus. However, it is giving the output of 10 random words. from nltk.corpus import brown import operator brown_tagged_sentences =…
Bonson
  • 1,418
  • 4
  • 18
  • 38
0
votes
0 answers

Function of nltk.TaggerI in Steven Bird's book

I am currently going through Steven Bird's NLP with Python. I have a question. What is the function of nltk.TaggerI? It's in chapter 6, Example 6-5. class ConsecutivePosTagger(nltk.TaggerI) I hope to get a better idea about it. Thanks
0
votes
1 answer

'str' object is not callable in NLTK

import re import nltk import pandas as pd from nltk.chunk import RegexpParser from textblob import TextBlob data = open('data.txt', 'r') data = data.read() # region Fetch Account Type chunkData = r"""DataChunk: {(++)} …
Vinay Sawant
  • 368
  • 2
  • 7
  • 23