lexic.js
Lexic analyser
Warning! It's not working now!
Now it's just a dictionaries, parsed to JSON. Sources of dictionaries mined from aot.ru
Usage
var Lexic = require('lexic');
Lexic.create({<options>}, function(error, lexic) {
if (err) throw err;
// lexic is a new lexic analyser
});
Documentation
In that distribution there are 3 dictionary json's. They are pretty heavy, so, you may remove those you aren't
interested in. You may find them in dic/
folder
Module
module.create(options, callback)
Arguments
-
options
- is an object of options. -
callback
- is a function, there will beerr
andlexic
passed into acallback
Options
-
lang
- is a language of creating dictionary. Now it can beru
,en
,de
lexic
it's a special object contains methods to analyze text. It has property lexic.dictionary
which is the reference to the dictionary
object
###lexic.analyze(string)
Method to parse the text. Now it's not working, just splitting text to sentences. Returns the array of strings.
lexic.findWord(string)
Method to find and collect data about word. It returns special object - word
Arguments
-
string
- a word, you want to find and wrap. You should pass into only string with no spaces, dots, commas, and other stuff. You will just get nothing useful, following another way.
dictionary
It's a special object contains massive JSON dictionary and some methods to work with it.
dictionary.parse(string, deep)
Method returns an array of theories. It is low levelled, so, I don't expect anyone will use it.
Theory is an object.
Theory properties
-
variants
- array of grammar elements -
base
- base grammar element of the theory -
assumption
- is the assumption of theory. Contain base - hypothetical lemma ofstring
, and ending - hypothetical ending ofstring
Arguments
-
string
- is a string you want to parse. Thestring
should be in language, you passed tooptions
ofLexic.create()
. -
deep
- boolean.false
by default. Iftrue
method will try to find every possible variant in dictionary, no matter how many variants it already founded.
dictionary.store(path, callback)
That method will help you to store loaded json. callback
will be called with only err
, if there will be smth wrong
dictionary.mine(options, callback)
I don't expect anyone will use that method, aot.ru do not update their dictionaries. That method will drop current loaded json dictionary, and may overwrite existing dictionaries, so, don't use it!
Arguments
-
options
- is an object of options. -
callback
-callback
will be called with onlyerr
, if there will be smth wrong
Options
-
dic
- is the path to main dictionary. Dictionary should be in aot.ru format. It often has extension.mrd
-
lang
- the language of mining dictionary. It changes thelang
of adictionary
-
gram
- a grammar file, it often sounds likeegramtab.tab
, from aot.ru too -
path
- path for storing json dictionary
###dictionary.load(callback)
A method to load json dictionary. It's only for initialization, don't use it!
word
Word is an object of result. It has possible variants of grammar forms of source string inside of it. Variants are int hre property word.variants
word.toString()
Returns source string
word.grammar([all])
Returns the string with description of the active variant of the grammar form of the word
Arguments
-
all
- boolean argument,false
by default. If true = method will return information about all grammar forms.
word.otherVariant()
Method will switch active variant of the grammar form.
word.getBase()
Method will try to find the base form of the word. It's not working good now