Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import natty to support natural language #36

Merged
merged 4 commits into from
Oct 27, 2016

Conversation

LiXiaoooowei
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 83.743% when pulling 45ec7cd on import-natty-to-support-natural-language into e1423ad on master.

@shixiyue
Copy link

I think you can merge after making it more defensive.

@@ -35,6 +41,11 @@
public AddCommand(String name, String deadline, Set<String> tags,String freq)
throws IllegalValueException {
final Set<Tag> tagSet = new HashSet<>();
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
if(!deadline.matches(DATE_VALIDATION_REGEX)&&!deadline.equals("")){
List<Date> date = new com.joestelmach.natty.Parser().parse(deadline).get(0).getDates();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it is an invalid date that cannot be parsed by natty? i.e. d/hi
In this case, new com.joestelmach.natty.Parser().parse(deadline) will return an empty array list which cause IndexOutOfBoundsException for get(0).
So perhaps you can check the size first?

@LiXiaoooowei LiXiaoooowei merged commit 7a5cada into master Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants