-->

How to determine if a sentence is talking about a

2020-07-30 03:43发布

问题:

I have predefined words and would like to know if the sentence primary subject is about the predefined words.

Example:

Predefined words: iPhone, Nexus, HTC

Sentence:

I like the new design of iPhone - primary subject is iPhone

I am listing to Nirvana on my Nexus. - primary subject is not in predefined words

The HTC phone is better than iPhone - primary subject is HTC

Would like to do this in PHP or something I that can have PHP interface.

回答1:

Alias-i has a natural language parser for PHP.

Edit: this page says Alias-i's parser is written in PHP, but Alias-i's website says it is written in Java.



回答2:

The short version: By Keywords.

This method works only with a limited set of Keywords.

A related question might be: Using preg_match to find all words in a list

The long version: By parsing the language and making the computer system understand it.

The later is something linguists do. They develop such systems and it takes years. Probably you find some implementations available, but I do not know any from memory. Would need to ask a friend.



回答3:

Try to get goog heurstic and evaluate them. Examples: 1. Keyword is at beginning of sentence. 2. There are only one keyword in text. 3. Is there are continius form like "litenining" etc usaly leadt to subjective/uninformative message.

Write classifier upon those features. I would recommend Mallet.



标签: php nlp