MAKE A JAVA FILE CALLED Pipeline
CODING ARE
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import java.util.Properties;
public class Pipeline {
private static Properties properties;
private static String propertiesName ="tokenize, ssplit, pos, lemma, ner";
private static StanfordCoreNLP stanfordCoreNLP;
private Pipeline() { }
static {
properties = new Properties();
properties.setProperty("annotators",propertiesName);
}
public static StanfordCoreNLP getPipeline()
{
if(stanfordCoreNLP ==null)
stanfordCoreNLP = new StanfordCoreNLP(properties);
return stanfordCoreNLP;
}
}
CREATE A JFRAME
WITH FOLLOWING CODING
mport edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.CoreDocument;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import java.util.List;
public class nerapp extends javax.swing.JFrame {
public nerapp() {
initComponents();
}
private void person_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("PERSON"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void location_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("LOCATION")|| nerr.equals("CITY")||nerr.equals("PROVINCE") ||nerr.equals("STATE"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void time_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("DATE"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void number_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("NUMBER"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void org_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("ORGANIZATION"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void title_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("TITLE"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void email_btnActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
//String text = "Jim bought 300 shares of Acme Corp. in 2006.";
String indata = intext.getText();
CoreDocument coreDocument = new CoreDocument(indata);
stanfordCoreNLP.annotate(coreDocument);
List<CoreLabel> coreLabelList = coreDocument.tokens();
int count =0;
for(CoreLabel coreLabel : coreLabelList)
{
String nerr = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(nerr.equals("EMAIL"))
{
outtext.append(coreLabel.originalText());
outtext.append("\n");
count++;
}
}
if(count==0)
{
outtext.setText("no entity found");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
outtext.setText("");
intext.setText("");
}
THE INTERFACE DESIGN IS

