Giter Site home page Giter Site logo

elliptical-datetime's People

Contributors

brandonhorst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bradvogel pie6k

elliptical-datetime's Issues

Need help

I am trying to create a parser to capture a datetime within a sentence.
So far, playing with elliptical and this library I have the following grammar:

  <sequence>
    <literal text='due by ' />
    <DateTime id='dueDate' past={false} prepositions />
    <freetext consumeAll />
  </sequence>

I want the freetext to consume and throw away everything after the datetime has been parsed. The problem is with an example sentence like so: "due by Tuesday at 5pm blah blah blah", it correctly identifies next Tuesday, but does not correctly set the time to 5pm. (If I remove the freetext element, it works without any text after the datetime).

Any insight would be appreciated.

Timezone awareness?

I'm evaluating time strings (such as 3pm) on my server, which might not be in the same timezone from where the string originates. This can result in incorrect parsing.

Do you have any pointers on how this can be fixed? I'm happy to file a PR.

Date no longer returned

The following code:

var lacona = require('lacona');
var laconaPhrase = require('lacona-phrase');
var datetime = require('lacona-phrase-datetime');
var string = require('lacona-phrase-string');
var parser = new lacona.Parser({
    grammar: laconaPhrase.createElement('sequence', {
        children: [
            laconaPhrase.createElement('literal', {
                text: 'remind me to '
            }),
            laconaPhrase.createElement(string.String, {
                id: 'activity'
            }),
            laconaPhrase.createElement('literal', {
                text: ' '
            }),
            laconaPhrase.createElement('choice', {
                id: 'date',
                children: [
                    laconaPhrase.createElement(datetime.DateTime, {
                        past: false
                    })
                ]
            })
        ]
    })
});

var _ = require('underscore');
var moment = require('moment');

function parse(text) {
    var results = parser.parseArray(text);
    var topResult = _.first(_.sortBy(results, 'score').reverse());
    return topResult ? topResult.result : null;
}

console.log(parse('remind me to exercise well in 36 hours'))

produces the output in version 0.7.1:

{ activity: 'exercise well',
  date: Tue Feb 16 2016 01:21:26 GMT-0800 (PST) }

but produces the output in version 0.8.0:

{ activity: 'exercise well',
  date: { time: { hour: 1, minute: 21, second: 51 }, timeOfDay: {} } }

The date object is missing in 0.8.0. Is that intentional? It makes it less useful without the date object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.