Defining grammar based rules and inferences in android

95 views Asked by At

I have to collect information from a source and classify the information based on certain rules. The input would be a text file. Eg: "Raj loves eating chocolates. Rohan likes flowers. Ravi is very popular."

From what I have learnt till date, we can tag the text based on nounphrases, verbphrase etc. So, I am planning to tag the text first. Now I want to define rules like:

if nounphrase appears after "love*" then add chocolate to the list. Similarly, if nounphrase appears after "like*" then add flowers to the list.

Now, for classification, I will create a RDF defining classes and individuals for chocolate and flowers.

My question here is 1. How do I define the grammar based rules in Android? 2. After getting the noun phrases how do I classify those nouns under a class of items of which is defined in the RDF?

Thanks.

1

There are 1 answers

3
ilomambo On BEST ANSWER

I assume you are asking about how to program,not how to use Android as OS.

Unfortunately there are no grammar tools in java for Android, you would have to use a parser for natural language (see this parser online, also has an API for programming).
Parsers like YACC, BISON, ANTLR or similar (you'll get a lot of info by Googleing those terms) are no good for you since they require unambiguous grammars, and natural language is nothing but unambiguous.

If your input is relatively simple you should consider using some sort of regular expression parsing and classification. It is much simpler and easier to implement. Java does support all sort of string manipulation with regular expressions.