Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing Meaning from Text

I realize this is a broad topic, but I'm looking for a good primer on parsing meaning from text, ideally in Python. As an example of what I'm looking to do, if a user makes a blog post like:

"Manny Ramirez makes his return for the Dodgers today against the Houston Astros",

what's a light-weight/ easy way of getting the nouns out of a sentence? To start, I think I'd limit it to proper nouns, but I wouldn't want to be limited to just that (and I don't want to rely on a simple regex that assumes anything Title Capped is a proper noun).

To make this question even worse, what are the things I'm not asking that I should be? Do I need a corpus of existing words to get started? What lexical analysis stuff do I need to know to make this work? I did come across one other question on the topic and I'm digging through those resources now.

like image 667
Tom Avatar asked Jul 17 '09 00:07

Tom


People also ask

What you mean by parsing?

parsed; parsing. transitive verb. : to divide (a sentence) into grammatical parts and identify the parts and their relations to each other. : to describe (a word) grammatically by stating the part of speech and explaining the inflection (see inflection sense 2a) and syntactical relationships.

What is parsing in communication?

Parsing is the process of breaking down a sentence into its elements so that the sentence can be understood. Traditional parsing is done by hand, sometimes using sentence diagrams. Parsing is also involved in more complex forms of analysis such as discourse analysis and psycholinguistics.

What is parsing in reading?

Parsing refers to the process of segmenting sentences into units of meaning. By doing so, readers process incoming data economically as memory and processing constraints limit the amount of data which can be dealt with at one time.

What is sentence parsing?

This cognitive activity, usually called syntactic analysis or sentence parsing, includes assigning a word class (part-of-speech) to individual words, combining them into word groups or 'phrases', and establishing syntactic relationships between word groups.


2 Answers

You need to look at the Natural Language Toolkit, which is for exactly this sort of thing.

This section of the manual looks very relevant: Categorizing and Tagging Words - here's an extract:

>>> text = nltk.word_tokenize("And now for something completely different")
>>> nltk.pos_tag(text)
[('And', 'CC'), ('now', 'RB'), ('for', 'IN'), ('something', 'NN'),
('completely', 'RB'), ('different', 'JJ')]

Here we see that and is CC, a coordinating conjunction; now and completely are RB, or adverbs; for is IN, a preposition; something is NN, a noun; and different is JJ, an adjective.

like image 52
RichieHindle Avatar answered Oct 26 '22 23:10

RichieHindle


Use the NLTK, in particular chapter 7 on Information Extraction.

You say you want to extract meaning, and there are modules for semantic analysis, but I think IE is all you need--and honestly one of the only areas of NLP computers can handle right now.

See sections 7.5 and 7.6 on the subtopics of Named Entity Recognition (to chunk and categorize Manny Ramerez as a person, Dodgers as a sports organization, and Houston Astros as another sports organization, or whatever suits your domain) and Relationship Extraction. There is a NER chunker that you can plugin once you have the NLTK installed. From their examples, extracting a geo-political entity (GPE) and a person:

>>> sent = nltk.corpus.treebank.tagged_sents()[22]
>>> print nltk.ne_chunk(sent) 
(S
  The/DT
  (GPE U.S./NNP)
  is/VBZ
  one/CD
  ...
  according/VBG
  to/TO
  (PERSON Brooke/NNP T./NNP Mossman/NNP)
  ...)

Note you'll still need to know tokenization and tagging, as discussed in earlier chapters, to get your text in the right format for these IE tasks.

like image 23
Bluu Avatar answered Oct 26 '22 23:10

Bluu