npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

orolo

v0.1.1

Published

An aggressive natural language dates parser for JavaScript

Downloads

12

Readme

Orolo

Yet another natural language dates parser for JavaScript with a focus on understanding dates and date ranges in a sentence. Orolo is an aggressive parser designed to work on sentenses that are known to contain dates.

Why

There are very good NLP date parses for JavaScript:

There are also strong general purpose NLP frameworks that some with pre-build named entity recognition for dates:

Unfortunately, I couldn't find one that would properly understand these sentences:

  • Will be in New York on May 5th, 6th, and 7th
  • Will be in London from june third till june sixth
  • I was in SFO this past Tue and Wed

and that's how orolo was born.

Install

npm install --save orolo

Usage

const { Orolo } = require('orolo');

const orolo = new Orolo();
const dates = orolo.recognize(
  'I will be in New York next week Tuesday and also Friday'
);

If you know that the dates in the sentence are not relative to today:

const context = new Date('2018-05-01');
const dates = orolo.recognize(
  'I am not available next week Mon - Wed',
  context
);

How It Works

Orolo works in two stages. First, it parses the sentence looking for date tokens. Then it computes the tokens by arranging them into a computable sequence.

Locales

Right now orolo only supports English but it is designed to support other languages as well. You will need to implement the ILocale interface. The best way to do it at the moment is to take a look at how EnglishLocale is implemented. In short, you specify how to tokenize a sentence, you also specify how many language tokens (words) can a date token span, and then you implement token detectors for each token type that orolo supports.

Aggressive Parsing

Orolo takes everything that looks like a valid date token and then attempts to compute a date. The following two sentenses will compute down to May 5th:

It happened on May 5
I bought 5 shirts in May

There is no logic currently to look at either dependency graph or proximity of tokens to each other.

Parsed Sequence

If you would like to take advantage of parsing logic but don't want/need orolo to compute the dates:

const { parse, EnglishLocale } = require('orolo');
const sequence = parse(
  'I will be in New York next week Tuesday and also Friday',
  new EnglishLocale()
);

// sequence.tokens will return an Array of parsed tokens