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.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
Pranav
  • 159
  • 1
  • 6

8 Answers8

24

Natty is a really good replacement for JChronic.

Tom Morris
  • 3,979
  • 2
  • 25
  • 43
  • 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 '11 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 '13 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 '14 at 09:10
  • 1
    nice you can even try out the parser in an online demo here: http://natty.joestelmach.com/try.jsp# – Gregor Oct 19 '18 at 13:43
3

You can use JChronic, the Java port of Chronic.

nico.ruti
  • 605
  • 6
  • 17
Guido
  • 46,642
  • 28
  • 120
  • 174
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).

nico.ruti
  • 605
  • 6
  • 17
Pontus Gagge
  • 17,166
  • 1
  • 38
  • 51
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.

João Silva
  • 89,303
  • 29
  • 152
  • 158
0

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

Natus Drew
  • 1,876
  • 1
  • 21
  • 23
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
Gregor
  • 1,297
  • 1
  • 19
  • 31
0

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

Bit-Man
  • 516
  • 4
  • 17
0

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

oroszgy
  • 123
  • 7