15

I am working on a Natural Language parser which examines a sentence in english and extracts some information like name, date etc.

for example: "Lets meet next tuesday at 5 PM at the beach."

So the output will be something like : "Lets meet 15/09/2009 at 1700 hr at the beach"

So basically, what i want to know is that is there any framework or library available for JAVA to do these kind of operations like parsing dates from a sentence and give a output with some specified format.

Regards, Pranav


Thanks for the replies. I have looked on few NLPs like LingPipe, OpenPL, Stanford NLP. I wanted to ask do they hav anything for date parsing for java.

2

8 Answers 8

24

Natty is a really good replacement for JChronic.

4
  • 7
    I swear Natty handles pretty much everything. For example, 2 wednesdays from now can't be parsed by any other solution I've found. +1
    – Dominic K
    Aug 28, 2011 at 21:08
  • 1
    I have a system where I'm being fed strings from which I need to (on a best guess basis) remove URLs, anything which might be HTML and anything which might be a date - I've found Natty is excellent for the latter, but I've built exceptions for April, May and June, which are valid girls' names.
    – Stewart
    Apr 24, 2013 at 14:28
  • 6
    Seems Natty has a problem with conflicting formats. Try 15/12/2004. It considers it as today 15th hour.
    – nawfal
    Jan 30, 2014 at 9:10
  • 1
    nice you can even try out the parser in an online demo here: natty.joestelmach.com/try.jsp#
    – Gregor
    Oct 19, 2018 at 13:43
3

You can use JChronic, the Java port of Chronic.

0
1

Have you tried jchronic? However, I doubt any library could directly work with sentences: you'd have to extract sentence fragments and feeding them to a NLP date parsing framework yourself, perhaps on a trial-n-error basis (larger and larger fragments until the framework throws an error).

0

I don't think there's any framework out there that does that out of the box. What you can do is create a set of regular expressions to match those patterns.

0

I would suggest using UIMA with OpenNLP connectors and same hand made regexp rules.

0

I wrote a NLP script in Python's NLTK and fed the results to Ruby's chronic.

0

For my use case, I had more luck with chrono-java - sadly it looks stale and is not available in any Maven repository (also not via https://jitpack.io/ since the build is broken), so you have to fix and build it for yourself.

However, checking out the code and fixing a dependency (maven-javadoc-plugin was missing groupId and I updated the version), allowed me to build and run a simple example successfully:

List<ParsedResult> results = Chrono.Parse("Datum  Freitag, 08.04. bis einschl. Sonntag 10.04.2016");
    results.forEach(result -> System.out.println(result));

resulted in 2 Dates being extracted:

ParsedResult: " 08.04" > 04/08/2018 12:00
ParsedResult: "10.04.2016" > 04/10/2016 12:00
0

Pretty old question bur PrettyTime::NLP is another option to try

Not the answer you're looking for? Browse other questions tagged or ask your own question.