Analysis of proposals and extraction of the name, organization and location of a person using NLP

I need to solve the following problems using NLP, can you give me directions on how to achieve this using the OpenNLP API

a. How to find out if any proposal involves any action in the past, present or future.

(eg) I was very sad last week - past I feel like hitting my neighbor - present I am planning to go to New York next week - future 

b. How to find a word that matches a person or company or country.

 (eg) John is planning to specialize in Electrical Engineering in UC Berkley and pursue a career with IBM). 

Person = John

Company = IBM

Location = Berkeley

thanks

+4
source share
2 answers

I can provide a solution

Solution b.

Here is the code:

  public class tikaOpenIntro { public String Tokens[]; public static void main(String[] args) throws IOException, SAXException, TikaException { tikaOpenIntro toi = new tikaOpenIntro(); String cnt; cnt="John is planning to specialize in Electrical Engineering in UC Berkley and pursue a career with IBM."; toi.tokenization(cnt); String names = toi.namefind(toi.Tokens); String org = toi.orgfind(toi.Tokens); System.out.println("person name is : "+names); System.out.println("organization name is: "+org); } public String namefind(String cnt[]) { InputStream is; TokenNameFinderModel tnf; NameFinderME nf; String sd = ""; try { is = new FileInputStream( "/home/rahul/opennlp/model/en-ner-person.bin"); tnf = new TokenNameFinderModel(is); nf = new NameFinderME(tnf); Span sp[] = nf.find(cnt); String a[] = Span.spansToStrings(sp, cnt); StringBuilder fd = new StringBuilder(); int l = a.length; for (int j = 0; j < l; j++) { fd = fd.append(a[j] + "\n"); } sd = fd.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (InvalidFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sd; } public String orgfind(String cnt[]) { InputStream is; TokenNameFinderModel tnf; NameFinderME nf; String sd = ""; try { is = new FileInputStream( "/home/rahul/opennlp/model/en-ner-organization.bin"); tnf = new TokenNameFinderModel(is); nf = new NameFinderME(tnf); Span sp[] = nf.find(cnt); String a[] = Span.spansToStrings(sp, cnt); StringBuilder fd = new StringBuilder(); int l = a.length; for (int j = 0; j < l; j++) { fd = fd.append(a[j] + "\n"); } sd = fd.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (InvalidFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sd; } public void tokenization(String tokens) { InputStream is; TokenizerModel tm; try { is = new FileInputStream("/home/rahul/opennlp/model/en-token.bin"); tm = new TokenizerModel(is); Tokenizer tz = new TokenizerME(tm); Tokens = tz.tokenize(tokens); // System.out.println(Tokens[1]); } catch (IOException e) { e.printStackTrace(); } } } 

and you want the location to also import the location model, which is also available in openGroup Source Forge . You can download and use them.

I’m not sure what will be the probability of the name, location and retrieval of the organization, but almost he will recognize all the names, location, organization.

and if openNLP is not found sufficient, then use Stanford Parser to recognize object names.

+6
source

Finding the literal sentence time is not trivial, but feasible in some cases. The OpenNLP parser will create a sentence structure from which you can try to extract the main verb, and a little morphological analysis will tell you whether the verb or the past is present (in English), and a little more deceives the “will” come in the future in the future model. it’s not always that simple. For example, in “Going to Paris desined my bank account” you have a built-in event (going to Paris) that happened in the past, but it's hard to understand. And your future example (“I plan ...” ) requires some real understanding of what the word "pl n ", which is quite difficult. This topic is the subject of current research in the field of natural language processing.

0
source

Source: https://habr.com/ru/post/1494691/


All Articles