Re:Bling Fire: Finite state machine and regular expression m...
by rthy on Thursday April 18, 2019 @02:19AM
(#19689122)
I have been experimenting with tokenization in Rust in https://github.com/rth/vtext, mostly relying on Unicode segmentation with a few custom rules for tokenization. The obtained performance was also around 10x faster than spacy for comparable precision (see benchmarks section of the readme).
Re:Bling Fire: Finite state machine and regular expression m...
by linkingday on Wednesday April 17, 2019 @10:45PM
(#19688328)
To further your point, NLTK is written in pure Python whereas the backend for spaCy, thinc, is written in C/C++/Python. Really no comparison here.
Re:Bling Fire: Finite state machine and regular expression m...
by avinium on Wednesday April 17, 2019 @11:09PM
(#19688416)
Anyone familiar enough with this library to explain how they've achieved such impressive performance? Otherwise, may dig into it for a blog post when I have time.
Re:Bling Fire: Finite state machine and regular expression m...
by sergeio76 on Thursday April 18, 2019 @12:34AM
(#19688727)
There are deterministic finite state machines underneath implemented in lean C++. These automata allow to implement operations with strings optimally or close to that. In the readme file there is a link to how to recompile linguistic resources, if you look inside the makefile that is used for resource compilation you will the steps.
Re:Bling Fire: Finite state machine and regular expression m...
by criddell on Thursday April 18, 2019 @10:40AM
(#19691325)
Do you use any kind of library or typical design pattern for your FSM implementation? When I've used them, I typically always go back to very C-like code (enum for the states, a state variable, and a big switch statement inside a loop).
Re:Bling Fire: Finite state machine and regular expression m...
by sergeio76 on Thursday April 18, 2019 @05:53PM
(#19695126)
We don't represent automata as a code, that leads to compiler errors etc., we represent them as graphs, just as data.
Inside the code we use: state --> int set of states --> sorted / unique'd array of int's input symbol --> int output symbol --> int transition function is abstracted out behind an interface and implemented differently based on whether automaton is read-only or changeable and based on the state etc.
Re:Bling Fire: Finite state machine and regular expression m...
by criddell on Friday April 19, 2019 @08:50AM
(#19699127)
I'm going to have to think about that a bit. Maybe I'm missing the point, but it sounds like an interpreter. Thanks for posting the code. This feels like something I need to understand.
Re:Bling Fire: Finite state machine and regular expression m...
by avinium on Thursday April 18, 2019 @01:50AM
(#19689019)
Thanks - will dive in and start checking things out.
Re:Bling Fire: Finite state machine and regular expression m...
by mlacks on Thursday April 18, 2019 @01:36AM
(#19688962)
What is lean C++?
Re:Bling Fire: Finite state machine and regular expression m...
by Abishek_Muthian on Thursday April 18, 2019 @02:16AM
(#19689114)
I think he just means efficient C++ programming.
Re:Bling Fire: Finite state machine and regular expression m...
by taf2 on Thursday April 18, 2019 @08:02AM
(#19690336)
#define WIN32_LEAN_AND_MEAN
Maybe ?
Re:Bling Fire: Finite state machine and regular expression m...
by lettergram on Wednesday April 17, 2019 @11:31PM
(#19688500)
One advantage is the core appears to be written in C/C++. NLTK is python and SpaCy is a lot of C/C++ with a significant amount of python.
I’ll have to dig in further, but I suspect there’s a lot of optimization for the task at hand here. SpaCy and NLTK tries to be much more general for NLP.
Re:Bling Fire: Finite state machine and regular expression m...
by avinium on Thursday April 18, 2019 @12:09AM
(#19688645)
I was more so referring to spacy, where (IIRC) a lot of the lower-level tokenization & parsing is written in Cython, so (I assume) the simple fact that Bling is written in C++ wouldn't explain the huge performance gains.
Re:Bling Fire: Finite state machine and regular expression m...
by stochastic_monk on Thursday April 18, 2019 @08:16AM
(#19690418)
There’s still a good amount of overhead in Cython portions of code unless there are no python objects or GIL involved, and then there’s still overhead communicating between C and Python worlds.
That’s part of why I stopped writing Cython and just use pybind11.
NLTK is designed for learning, not for production systems, speed or efficiency. The code is often the most straight-forward way to implement an algorithm, especially to read the code later.