All Projects → quire-io → Swiftychrono

quire-io / Swiftychrono

Licence: mit
A natural language date parser in Swift (ported from chrono.js)

Programming Languages

javascript
184084 projects - #8 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to Swiftychrono

Neusum
Code for the ACL 2018 paper "Neural Document Summarization by Jointly Learning to Score and Select Sentences"
Stars: ✭ 143 (-3.38%)
Mutual labels:  natural-language-processing
Googlelanguager
R client for the Google Translation API, Google Cloud Natural Language API and Google Cloud Speech API
Stars: ✭ 145 (-2.03%)
Mutual labels:  natural-language-processing
Turkce Yapay Zeka Kaynaklari
Türkiye'de yapılan derin öğrenme (deep learning) ve makine öğrenmesi (machine learning) çalışmalarının derlendiği sayfa.
Stars: ✭ 1,900 (+1183.78%)
Mutual labels:  natural-language-processing
Speechrecognizerbutton
UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.
Stars: ✭ 144 (-2.7%)
Mutual labels:  siri
Ai Job Info
互联网大厂面试经验
Stars: ✭ 145 (-2.03%)
Mutual labels:  natural-language-processing
Hands On Natural Language Processing With Python
This repository is for my students of Udemy. You can find all lecture codes along with mentioned files for reading in here. So, feel free to clone it and if you have any problem just raise a question.
Stars: ✭ 146 (-1.35%)
Mutual labels:  natural-language-processing
Stanza Old
Stanford NLP group's shared Python tools.
Stars: ✭ 142 (-4.05%)
Mutual labels:  natural-language-processing
Pycantonese
Cantonese Linguistics and NLP in Python
Stars: ✭ 147 (-0.68%)
Mutual labels:  natural-language-processing
Scientific Paper Summarisation
Machine learning models to automatically summarise scientific papers
Stars: ✭ 145 (-2.03%)
Mutual labels:  natural-language-processing
Words counted
A Ruby natural language processor.
Stars: ✭ 146 (-1.35%)
Mutual labels:  natural-language-processing
Multihead Siamese Nets
Implementation of Siamese Neural Networks built upon multihead attention mechanism for text semantic similarity task.
Stars: ✭ 144 (-2.7%)
Mutual labels:  natural-language-processing
Awesome Nlp Resources
This repository contains landmark research papers in Natural Language Processing that came out in this century.
Stars: ✭ 145 (-2.03%)
Mutual labels:  natural-language-processing
Char Cnn Text Classification Pytorch
Character-level Convolutional Neural Networks for text classification in PyTorch
Stars: ✭ 147 (-0.68%)
Mutual labels:  natural-language-processing
Monkeylearn Python
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.
Stars: ✭ 143 (-3.38%)
Mutual labels:  natural-language-processing
Tree Transformer
Implementation of the paper Tree Transformer
Stars: ✭ 148 (+0%)
Mutual labels:  natural-language-processing
Tod Bert
Pre-Trained Models for ToD-BERT
Stars: ✭ 143 (-3.38%)
Mutual labels:  natural-language-processing
Nl2sql
阿里天池首届中文NL2SQL挑战赛top6
Stars: ✭ 146 (-1.35%)
Mutual labels:  natural-language-processing
Dialogflow Ruby Client
Ruby SDK for Dialogflow
Stars: ✭ 148 (+0%)
Mutual labels:  natural-language-processing
Negapoji
Japanese negative positive classification.日本語文書のネガポジを判定。
Stars: ✭ 148 (+0%)
Mutual labels:  natural-language-processing
Fxdesktopsearch
A JavaFX based desktop search application.
Stars: ✭ 147 (-0.68%)
Mutual labels:  natural-language-processing

SwiftyChrono

A natural language date parser in Swift, designed to extract date information from any given text.

When we were integrating Siri with our iOS app, we found that JavascriptCore runtime is running on resource-limited extensions and will crash due to memory limitation. So, we created a Swift version. Thanks to Wanasit Tanakitrungruang's chrono.js.

SwiftyChrono supports most date and time formats, such as:

  • Today, Tomorrow, Yesterday, Last Friday, etc
  • 17 August 2013 - 19 August 2013
  • This Friday from 13:00 - 16.00
  • 5 days ago
  • Sat Aug 17 2013 18:40:39 GMT+0900 (JST)
  • 2014-11-30T08:15:30-05:30

There are more available patterns. You can simply download it and try.

Status

This project is currently being used in the Quire iOS app.

Requirements

Swift 4.2

  • Xcode 10
  • Swift 4.2

Swift 3

  • iOS 9.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
  • Xcode 8
  • Swift 3.0
  • 64 bit device (didn't test on 32 bit device)

Install

CocoaPods

use_frameworks!

target 'MyApp' do
	pod 'SwiftyChrono'
end

Usage

Initialization

import SwiftyChrono
let chrono = Chrono()

Parse

chrono.parse(text: "Bring a book tomorrow")
// [
// 	SwiftyChrono.ParsedResult(ref: 2017-02-22 08:33:33 +0000,
// 	index: 13,
// 	text: "tomorrow",
// 	tags: [
// 		SwiftyChrono.TagUnit.enCasualDateParser: true
// 	],
// 	start: SwiftyChrono.ParsedComponents(
// 		knownValues: [
// 			SwiftyChrono.ComponentUnit.day: 23,
// 			SwiftyChrono.ComponentUnit.year: 2017,
// 			SwiftyChrono.ComponentUnit.month: 2],
// 		impliedValues: [
// 			SwiftyChrono.ComponentUnit.minute: 0,
// 			SwiftyChrono.ComponentUnit.second: 0,
// 			SwiftyChrono.ComponentUnit.millisecond: 0,
// 			SwiftyChrono.ComponentUnit.hour: 12
// 		]),
// 	end: nil,
// 	isMoveIndexMode: false)
// ]

// refDate (1485921600000) is 2017/2/1 12:00:00.0000
let refDate = Date(timeIntervalSince1970: 1485921600)
// you can add a reference date
chrono.parse(text: "Bring a book tomorrow", refDate: refDate)

Quick Date Parse

chrono.parseDate(text: "Bring a book tomorrow", refDate: refDate)
// "Feb 2, 2017, 12:00 PM"

Other Options

// options: .forwardDate - the match date is always later than refDate
chrono.parseDate(text: "Bring a book on December 1", refDate: refDate)
// "Dec 1, 2016, 12:00 PM"
chrono.parseDate(text: "Bring a book on December 1", refDate: refDate, opt: [.forwardDate: 1])
// "Dec 1, 2017, 12:00 PM"

// you can assignee which hour in 
// morning, afternoon, evening, noon
chrono.parseDate(text: "Bring a book tomorrow morning", refDate: refDate, opt: [.morning: 10])
// "Feb 2, 2017, 10:00 AM"

/// specify the preferred language will let the answer more acurate
chrono.parse(text: "you can do it tomorrow", refDate: refDate).map{ $0.text }
// ["do", "tomorrow"]
Chrono.preferredLanguage = .english
chrono.parse(text: "you can do it tomorrow", refDate: refDate).map{ $0.text }
// ["tomorrow"]


/// specify sixMinutesFixBefore1900 to true, if the date before 1900 is in your use case
Chrono.sixMinutesFixBefore1900 = true
chrono.parseDate(text: "you can do it 1970/1/1")


/// override defaut hour, minute, second, millisecond
// the default implied hour is 12 pm if the given text doesn't specify
Chrono.defaultImpliedHour = 1
Chrono.defaultImpliedMinute = 1
Chrono.defaultImpliedSecond = 1
Chrono.defaultImpliedMillisecond = 1
chrono.parseDate(text: "you can do it tomorrow", refDate: refDate)?.timeIntervalSince1970
// 1485968461.001, 2017/2/1 01:01:01.001

Demo Video

Everything Is AWESOME

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].