5
$\begingroup$

I am looking for algorithms to classify words in a paragraph of text. I am particularly interested in a classification to determine if a certain word is noun, verb, etc., but also looking for any kind of word-classification algorithms. I am given a smaller input (e.g. 200 words) so there is no many options for machine learning but I would really appreciate algorithms involving machine learning.

$\endgroup$
2
  • $\begingroup$ Is the text in a known language? $\endgroup$ Commented Aug 30, 2013 at 13:21
  • $\begingroup$ @YuvalFilmus Yes, I am sorry. It is in English $\endgroup$
    – gen
    Commented Aug 30, 2013 at 14:48

3 Answers 3

5
$\begingroup$

As D.W. said, the task of classifying words as noun, verb, etc. is called part-of-speech tagging:

enter image description here

The machine learning algorithm typically used for this purpose is the Log-Linear Model (aka. Maximum-Entropy, in short MaxEnt). It is actually pretty straightforward:

  • Assume you read the sentence sequentially (left to right, or right to left)
  • Let $h$ be the history of the last 2 tags you have assigned to the 2 previous words in the sentence as well as the list of all the words in your sentence.
  • Let $t$ be the tag you assign to the current word.
  • You defined many features $f_i(h, t)$, typically some indicator functions like $f_i(h, t)=1$ if current word ends with 'ing`, $f_i(h, t)=0$ otherwise.
  • $v$ is a parameter vector with the same number of elements of the number of features $f_i(h, t)$. $v$ is used to weight the features.
  • You define $p(t_i|t_{i-1},t_{i-2},w_1,...,w_n) = \frac {\exp \left( \sum_{i} v_i f_i(h, t) \right)\ }{\sum_{t'} \exp \left(\sum_{i} v_i f_i(h, t') \right)\ }$ (this is named multinomial logistic regression, a.k.a. maximum entropy (MaxEnt) classifier, multiclass logistic regression, polytomous logistic regression, softmax regression.)
  • Use Markov assumption: $p(t_1...t_n|w_1...w_n) = \prod_{i=1}^{n} p(t_i|t_{i-1},t_{i-2},w_1,...,w_n)$ (that's the probability that your sentence $w_1,...,w_n$ has tags $t_1,...,t_n$)
  • You find the $t_1,...,t_n$ that maximizes $\prod_{i=1}^{n} p(t_i|t_{i-1},t_{i-2},w_1,...,w_n)$ using the Viterbi algorithm: that's the final tagging of your sentence.
  • You train the model ($v$) so that it maximizes the likelihood of your training set (and add some regularization to improve generalization)

Most of the work to improve this main idea is about:

  • Finding better features
  • Do some reranking (e.g. Global Linear Models, which allows to define global features that take as inputs the entire tagging history, and not just the last 2 tags as before, whose feature weights are trained with some gradient descent like algorithm)

As usual, the more data, the better.

For more details see Coursera's Natural Language Processing by Michael Collins (Coursera's Natural Language Processing by Dan Jurafsky and Christopher Manning is great too).

Note that the task to locate and classify elements in text into pre-defined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc. is called Named-entity recognition.

$\endgroup$
0
5
$\begingroup$

This is a standard problem in Natural Language Processing (NLP).

Classifying whether each word is a noun, verb, etc., is known as "part-of-speech tagging". Searching on that term should turn up a lot of information about how to do that.

If you want to tag the words in some other way, you might be able to use other tagging algorithms. They generally use some sort of machine learning approach and will probably require a large training set (200 words won't be enough).

$\endgroup$
2
  • $\begingroup$ Thanks for the answer. Actually, I would like to implement one of the simplest tagging algorithms. Could you please give me some examples or websites of (taggings using machine learning) where I can proceed to. $\endgroup$
    – gen
    Commented Aug 31, 2013 at 6:21
  • $\begingroup$ @gen, like I said, search for "part-of-speech tagging". You should find a lot of resources (e.g., the Stanford parser). Use Google and spend some time investigating everything that is known. Yes, you'll have to do some research on your own. $\endgroup$
    – D.W.
    Commented Aug 31, 2013 at 6:56
0
$\begingroup$

Sadly, the English language has denied even the most brilliant Scientists a way to answer this question. I have been working in the area of geometric representations of the English Language for Memory Modelling and I've (maybe somewhat prematurely) come to the conclusion that the unbalanced laws of the English language allow it to mutate continuously with often contradictory and logically infeasible states.

Still the game is great to play and I can see no reason that with the right direction a computer of an imaginable amount of muscle could possibly implement learning algorithms to properly understand the nature of the English Language.

....Quantum Mechanics does provide some interesting leads though :-)

$\endgroup$
1
  • $\begingroup$ Your answer seems to say that part of speech tagging is impossible. While we don't know how to do it perfectly, there seem to be various techniques that are a lot better than just throwing your hands up and saying, "You can't do it." $\endgroup$ Commented Jun 18, 2014 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.