Crates.io | date_time_parser |
lib.rs | date_time_parser |
version | 0.2.0 |
source | src |
created_at | 2020-04-21 03:58:15.031572 |
updated_at | 2022-08-29 01:19:50.515741 |
description | Rust NLP library for parsing English natural language into dates and times |
homepage | |
repository | https://github.com/isaacrlee/event-parser |
max_upload_size | |
id | 232404 |
size | 35,002 |
Natural language date, time and event parsing libraries for Rust
Event Parser contains an date and time natural language parsing library, and event parsing library, as well as a client that demonstrates how to leverage these crates for a simple command-line tool. Written in Rust, the libraries build on the chrono
and regex
crates to deliver a library that provides more extensive coverage of natural language statements.
It aims to parse unstructered text into NaiveDate
and NaiveTime
formats.
Put this in your Cargo.toml
:
[dependencies]
date_time_parser = "0.1.0"
Then put this in your crate root:
extern crate date_time_parser;
General use of this package involves passing English natural language that includes a date to the DateParser
struct to parse the expression. If a date is found, it will parse the expression into the NaiveDate
format.
use date_time_parser::DateParser;
use chrono::NaiveDate;
let date = DateParser::parse("Lunch on June 5th");
assert_eq!(date, Some(NaiveDate::from_ymd(2020, 6, 5)));
For more examples and usage, please refer to the docs.
Aims to parse unstructered text into iCalendar Events
.
date_time_parser
for parsing out the dates and time of events.Put this in your Cargo.toml
:
[dependencies]
event_parser = "0.1.0"
Then put this in your crate root:
extern crate event_parser;
Pass English natural language that describes an event to the to_event
function to parse the expression. It will parse the expression into the iCalendar Events
format.
If applicable, the event will have a start and end time, or be classified as an all-day event. Addtionally, a date will be parsed for the event, defaulting to the current day if no date is found. The event will also have a summary (the name of the event), if one is given.
use event_parser::to_event;
use chrono::{Duration, Local};
use icalendar::{Component, Event};
let event = to_event("Dinner at 7");
let expected_event = Event::new()
.summary("Dinner")
.starts(Local::today().and_hms(19, 0, 0))
.ends(Local::today().and_hms(19, 0, 0) + Duration::hours(1))
.done();
assert!(equal(event, expected_event));
For more examples and usage, please refer to the docs.
To play around with what is possible with the event_parser
library, we've provided a command-line tool to be able to test different inputs easily. Simply download the repo and from the root of the project run cargo run
and type an natural English language event to see how it is parsed!
Install the Rust programming language, and then clone this repository.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
git clone https://github.com/isaacrlee/event-parser.git
To run the program and easily play with inputs:
cargo run
To run the test suite:
cargo test --all
Distributed under the MIT license. See LICENSE
for more information.
Copyright (c) 2020 Isaac Lee and Alex Grimes