I should use natty-master in my android project. But i couldn't import it. How can i use natty without maven? I find these codes, i added jars but it doesn't work.
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.joestelmach.natty.*;
public class natty {
public static void main(String[] args) {
Parser parser = new Parser();
List<DateGroup> groups = parser.parse("the day before next thursday");
for(DateGroup group:groups) {
Date dates = group.getDates().get(0);
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();
}
}
}
I investigated it for you a little bit.
I assume you're using Eclipse with current version of ADT plugin. First let's ensure you're adding jars properly:
libson root level of your project (alongside thesrc,res, etc.).libs.Now for the libraries. All dependencies of
natty-07.jarlisted by Maven are:Yep, that's 2.3 MB of dependencies you have to copy into
libs.I don't think all of them are necessary at runtime, but I have no way to tell which ones are crucial.
Using ProGuard probably could slim down some of them, but that's another story.
I created quick 'n dirty application with minSdkVersion="8" and targetSdkVersion="17". Then put sample code you provided into Activity and run it against input:
"the day before next thursday". As a result I got single group with date[Wed May 22 16:52:49 GMT 2013], which is OK since today is Friday May 17.Edit 2013-06-02
essential code:
http://pastebin.com/XrF5k10M
complete solution:
https://www.dropbox.com/sh/qk2cs51twrpobuz/YaFZWiG5jP/StackOverflow/16610375/NattyApp.zip