0

I am calling a service that analyzes a paragraph and highlights concepts/words that I provide in this format

{
"paragraph": "My dog got sick on 12/13/2010. Then he died on 01/13/2011."
"concept":[
    {
    "start": "6",
    "end": "9",
    "word": "sick"
    },
    {
    "start": "35",
    "end": "38",
    "word": "died"
    }]
}

What is the best way to relate the date to the word/concept?

I have tried doing a sentence parsing and working with regex and it gave some success but for more complicated paragraphs and sentence structures, it was failing.

If anyone has suggestions or recommends some type of NLP framework, it would be most appreciated.

Example of what I might the end result to look like:

    {
"paragraph": "My dog got sick on 12/13/2010. Then he died on 01/13/2011."
"concept":[
    {
    "start": "6",
    "end": "9",
    "word": "sick",
    "date" 12/13/2010"
    },
    {
    "start": "35",
    "end": "38",
    "word": "died",
    "date" 01/13/2011"
    }]
}

I am using STS, JAVA 8, Spring Frameworks

leedud
  • 15
  • 4

1 Answers1

0

Selection of Natural Language Processing(NLP) framework depends on various criteria such as problem domain, type of application, processes you want to perform, performance, language of choice, how do you want to use NLP software - as a library, standalone tool or a complete system and more.

You should establish a list of criteria that could help to best decide the tool for language processing for your scenario.

These are some of the widely used Java NLP softwares:

  1. Apache OpenNLP(Library)
  2. Stanford CoreNLP(complete system)
  3. UMASS Mallet(Package)
  4. Natty(Date-parser)

You could use Natty if you are specifically looking for a Natural Language Date Parser.

import com.joestelmach.natty.*;

Parser parser = new Parser();
List groups = parser.parse("the day before next thursday");

for(DateGroup group:groups) {
   List dates = group.getDates();
   int line = group.getLine();
   int column = group.getPosition();
   String matchingValue = group.getText();
   String syntaxTree = group.getSyntaxTree().toStringTree();
   Map> parseMap = group.getParseLocations();
   boolean isRecurreing = group.isRecurring();
   Date recursUntil = group.getRecursUntil();
}

Code Source: Natty

Other Helpful Links:

  1. Natural Language date and time parser for java

  2. Algorithm to detect time, date and place from invitation text

Hope it helps!

babybear
  • 804
  • 1
  • 10
  • 24