Python Forum
serious n00b.. NLTK in python 2.7 and 3.5
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serious n00b.. NLTK in python 2.7 and 3.5
#11
The error message is telling you that it's already installed in python 3.5

Have you downloaded and installed the corpus?

if not, see: http://www.nltk.org/data.html

I have never used it on an Apple (don't own one) and never from a shell.
Reply
#12
yes, i downloaded using
Jordans-MBP:~ jordan$ python3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> nltk.download()
showing info https:// raw.githubusercontent.com/nltk/nltk_data/gh-pages/index
and that automatically brings me to download just about all of the corpora that you linked through the website.

so basically, if I'm using virtual studio code and my terminal functions fine when using python3 code then it would be irrelevant and perhaps superfluous to use IDLE shell in any instance, is that correct?
Reply
#13
Well, you can use it in idle, why not.
It wouldn't be my choice but that's beside the point.

Whatever it is that you are trying to do, should be written in a python script.

It would not make sense to try and do anything other than elementary stuff in a shell!
Reply
#14
well-said, perfect. that brings some good clarification.

EDIT:

thanks for your guys' patience; it's literally my first 36 hours attempting coding and i've spent 15 trying to just get set up and going in the right direction
Reply
#15
If you think thats bad, wait for C/C++ compiling, linking libraries , makefiles, etc.
Recommended Tutorials:
Reply
#16
hahaha touché ...

C++ will be my next language in probably 10 years once I finally understand python.

i've read about those terms and they go right over my head.

it's not so bad as it is a bit frustrating when I feel like I'm going backwards and have no friggin clue what i'm doing, then it gets solved, and then i'm head-first into another wall.

I'm sure with a bit of experience and some direction when needed from smart folks like you, I'll be just fine.
Reply
#17
I like C++, used it for years, C (as major language) before and during that time.
Finding and linking libraries was always a pain, and I considered myself an expert at Make,
in fact I was the author of the (as far as i know) Makemake reverse engineering program that
created a make file from source code.


Here's the scoop:

1. As Metluburr stated - Why have to deal with make, compile, boost, librarian etc. etc. Sure, it
  runs faster in many cases, and if that is a real issue, by all means have at it.

2. So far, I have been able to do everything that I want to do in Python, with ease, so until someone
   comes out with something better. This will be my language, and I plan on programming until at
   least 90. I'll reevaluate then!
Reply
#18
wow that's impressive. how did you get started and what do you aim to accomplish ultimately?

I am aware of what my end-goals are but I'm just unsure of how to get there so after some research I've read python is a good place to get started given the tools into the direction I'd like to head.

i find the learning curve of the layout of the language pretty easy now that it's running semi-properly. i'm still having some issues but I'm sure I'll be able to work them out in due time. 
for example after doing some sentdex exercises I've run into an error like this:

CODE:
import nltk
from nltk.corpus import state_union
from nltk.tokenize import PunktSentenceTokenizer

train_text = state_union.raw("2005-GWBush.txt")
sample_text = state_union.raw("2006-GWBush.txt")
custom_sent_tokenizer = PunktSentenceTokenizer(train_text)
tokenized = custom_sent_tokenizer.tokenize(sample_text)

def process_content():
   try:
       for i in tokenized:
           words = nltk.word_tokenize(i)
           tagged = tagged.pos_tag(words)
           print(tagged)

   except Exception as e:
       print(str(e))

process_content()
Error:
DEBUG: local variable 'tagged' referenced before assignment
and i've read that I maybe need to put a "return" in somewhere but I just don't know where and I've read that maybe a "global" somewhere would help but it could mess the code up in longer iterations.

then when I put the coding into the terminal to run it I get numerous syntax, unexpected indent errors, etc. so, working in visual studio code is getting me more experience for now but it's just frustrating when I can't replicate semi-simple tasks as I'm seeing others do when I've duplicated the code line-by-line.
alas, patience and experience.

EDIT: i'm unsure of why the indentations are edited out and they're all uniform but I assure you they are indented properly and if you can tell me how to maintain paragraph continuity when pasting code, that'd be super helpful for future questions. I used the BBCode accidentally on my first post and was rightfully issued a warning; i just want to abide by the rules of the forum and it's not my intention to break them. ignorance is no excuse, I'm just learning as I go with what I've read from helpful people who have posted links within this very thread.

thanks again.
Reply
#19
There are 3 buttons in the message box you will probably use most often, the "Quote" (7th button from right), "Python" for posting your code (6th button from right) and "Red X" for posting errors (5th button from right).
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#20
TEST:
sudo pip69 install -U nltk
Output:
none
Error:
user is stupid
edit: thank you so much

def process_content():
    try:
        for i in tokenized:
            words = nltk.word_tokenize(i)
            tagged = nltk.pos_tag(words)
            print(tagged)

    except Exception as e:
        print(str(e))
i realized i had "tagged=tagged.pos_tag(words)" instead of what you see above. Wall
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with simple nltk Chatbot Extra 3 1,891 Jan-02-2022, 07:50 AM
Last Post: bepammoifoge
  Saving a download of stopwords (nltk) Drone4four 1 9,331 Nov-19-2020, 11:50 PM
Last Post: snippsat
  Installing nltk dependency Eshwar 0 1,838 Aug-30-2020, 06:10 PM
Last Post: Eshwar
  n00b question millpond 6 3,379 Jul-13-2019, 06:41 AM
Last Post: Gribouillis
  Clean Data using NLTK disruptfwd8 0 3,337 May-12-2018, 11:21 PM
Last Post: disruptfwd8
  n00b help with referencing files theturd 8 5,128 Jul-21-2017, 04:16 PM
Last Post: nilamo
  n00b needs help theturd 8 5,816 Jun-12-2017, 01:55 PM
Last Post: theturd
  Text Processing and NLTK (POS tagging) TwelveMoons 2 4,906 Mar-16-2017, 02:53 AM
Last Post: TwelveMoons
  NLTK create corpora pythlang 5 10,205 Oct-26-2016, 07:31 PM
Last Post: Larz60+
  Corpora catalof for NLTK Larz60+ 1 4,120 Oct-20-2016, 02:31 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020