Live data from Hacker News

Teaching a Computer to Read: NLP Hacking in Python

blog.scripted.com

21–25 of 25 posts

Re: Teaching a Computer to Read: NLP Hacking in Python

#21
post #17
post #4

Earlier quoted context omitted.

In fact, if your training corpus is sufficiently large, you'd be shocked how many words you can eliminate right away for a term frequency of one or two. I went from millions of words in the vocabulary to something like 60k just by ignoring words that happen once or twice in the corpus. Plus, you probably won't learn much about the relationships between words if they only occur a few times in the corpus.

Yeah, but consider that some rare words are much stronger indicators of topic than more common ones. Even more so if you look at n-grams. If you use something like wordnet you can get a lot of meaning out of low-frequency words and throw away the meaningless higher-frequency ones that occur in too many categories to be useful.

Sure, there's value in rare words, but I don't think anything that occurs across the corpus fewer than 3 times is going to tell you anything useful. You need a certain amount just to have it be a real signal. What was the least frequent useful word in the data set, msalahi?

Re: Teaching a Computer to Read: NLP Hacking in Python

#22
post #12

Earlier quoted context omitted.

Saw you are trying it out. Awesome! Sorry the documentation is a bit weak right now, we had people wanting it so we got it out, rather than getting all the docs complete.

I did try it out. It does a good job of pulling out different bits and categorizing them. I went ahead and ran the example you had and put it up to continue the conversation( https://gist.github.com/adpreese/6722561 ). If you want me to take it down, I will certainly respect that but I thought it'd be convenient for anyone else paying attention. The noun phrases part of the response gave a concise list of things, inc…

Play with the http://TLDRStuff.com tools there is zero learning curve over there.

One of the API's takes a URL, one takes plaintext or HTML, not sure which one you hit, but the TLDRStuff.com will make it really easy for you to play.

Re: Teaching a Computer to Read: NLP Hacking in Python

#23
post #12

Earlier quoted context omitted.

Saw you are trying it out. Awesome! Sorry the documentation is a bit weak right now, we had people wanting it so we got it out, rather than getting all the docs complete.

I did try it out. It does a good job of pulling out different bits and categorizing them. I went ahead and ran the example you had and put it up to continue the conversation( https://gist.github.com/adpreese/6722561 ). If you want me to take it down, I will certainly respect that but I thought it'd be convenient for anyone else paying attention. The noun phrases part of the response gave a concise list of things, inc…

We have the groupings and we can use sentiment to get the importance. The API is somewhat limited compared to our full bag of tricks, mostly because we don't want to give away all of our secrets, but also because we change things pretty often and would have to let others know when we made changes if they were consuming an API.

Re: Teaching a Computer to Read: NLP Hacking in Python

#24
Actually, I think you could save yourself some trouble and use scikit-learn's built-in text preprocessing utils:

Word counter: http://scikit-learn.org/stable/modules/generated/sklearn.fea...

Hashing vectorizer if you want to trade off explainability for speed and scalability: http://scikit-learn.org/stable/modules/generated/sklearn.fea...

TF-IDF weighing: http://scikit-learn.org/stable/modules/generated/sklearn.fea...

Also, if you transform bag-of-words vectors into a dense form, you're gonna have a bad time (insert appropriate meme picture here). In large corpora, dimensionality grows quite substantially - if you work with news corpora or Wikipedia, you're in the 100k-1M dimensional space pretty quickly.

Great to see an approachable explanation for NLP. As they say sometimes, when you know how it's done, it stops being "Artificial Intelligence".

Post reply on HN