when alternatives and similar packages
Based on the "Natural Language Processing" category.
Alternatively, view when alternatives based on common mentions on social networks and blogs.
-
prose
:book: A Golang library for text processing, including tokenization, part-of-speech tagging, and named-entity extraction. -
gse
Go efficient multilingual NLP and text segmentation; support English, Chinese, Japanese and others. -
spaGO
Self-contained Machine Learning and Natural Language Processing library in Go -
universal-translator
:speech_balloon: i18n Translator for Go/Golang using CLDR data + pluralization rules -
locales
:earth_americas: a set of locales generated from the CLDR Project which can be used independently or within an i18n package; these were built for use with, but not exclusive to https://github.com/go-playground/universal-translator -
RAKE.go
A Go port of the Rapid Automatic Keyword Extraction algorithm (RAKE) -
go-nlp
Utilities for working with discrete probability distributions and other tools useful for doing NLP work. -
segment
A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29 -
textcat
A Go package for n-gram based text categorization, with support for utf-8 and raw text -
go-localize
i18n (Internationalization and localization) engine written in Go, used for translating locale strings. -
stemmer
Stemmer packages for Go programming language. Includes English, German and Dutch stemmers. -
petrovich
Golang port of Petrovich - an inflector for Russian anthroponyms. -
go-tinydate
A tiny date object in Go. Tinydate uses only 4 bytes of memory -
spreak
Flexible translation and humanization library for Go, based on the concepts behind gettext. -
gotokenizer
A tokenizer based on the dictionary and Bigram language models for Go. (Now only support chinese segmentation) -
golibstemmer
Go bindings for the snowball libstemmer library including porter 2
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of when or a related project?
Popular Comparisons
README
when
when
is a natural language date/time parser with pluggable rules and merge strategies
Examples
- tonight at 11:10 pm
- at Friday afternoon
- the deadline is next tuesday 14:00
- drop me a line next wednesday at 2:25 p.m
- it could be done at 11 am past tuesday
Check EN, RU and BR rules and tests for them, for more examples.
Needed rule not found? Open an issue with the case and it will be added asap.
How it works
Usually, there are several rules added to the parser's instance for checking. Each rule has its own borders - length and offset in provided string. Meanwhile, each rule yields only the first match over the string. So, the library checks all the rules and extracts a cluster of matched rules which have distance between each other less or equal to options.Distance
, which is 5 by default. For example:
on next wednesday at 2:25 p.m.
└──────┬─────┘ └───┬───┘
weekday hour + minute
So, we have a cluster of matched rules - "next wednesday at 2:25 p.m."
in the string representation.
After that, each rule is applied to the context. In order of definition or in match order, if options.MatchByOrder
is set to true
(which it is by default). Each rule could be applied with given merge strategy. By default, it's an Override strategy. The other strategies are not implemented yet in the rules. Pull requests are welcome.
Usage
w := when.New(nil)
w.Add(en.All...)
w.Add(common.All...)
text := "drop me a line in next wednesday at 2:25 p.m"
r, err := w.Parse(text, time.Now())
if err != nil {
// an error has occurred
}
if r == nil {
// no matches found
}
fmt.Println(
"the time",
r.Time.String(),
"mentioned in",
text[r.Index:r.Index+len(r.Text)],
)
Distance Option
w := when.New(nil)
w.Add(en.All...)
w.Add(common.All...)
text := "February 23, 2019 | 1:46pm"
// With default distance (5):
// February 23, 2019 | 1:46pm
// └───┬───┘
// distance: 9 (1:46pm will be ignored)
r, _ := w.Parse(text, time.Now())
fmt.Printf(r.Time.String())
// "2019-02-23 09:21:21.835182427 -0300 -03"
// 2019-02-23 (correct)
// 09:21:21 ("wrong")
// With custom distance (10):
w.SetOptions(&rules.Options{
Distance: 10,
MatchByOrder: true})
r, _ = w.Parse(text, time.Now())
fmt.Printf(r.Time.String())
// "2019-02-23 13:46:21.559521554 -0300 -03"
// 2019-02-23 (correct)
// 13:46:21 (correct)
State of the project
The project is in a more-or-less complete state. It's used for one project already. Bugs will be fixed as soon as they will be found.
TODO
- [ ] readme: describe all the existing rules
- [ ] implement missed rules for these examples
- [ ] add cli and simple rest api server(#2)
LICENSE
*Note that all licence references and agreements mentioned in the when README section above
are relevant to that project's source code only.