Loading WordNet Database
In order to enable better semantic analysis of tokens in user input it is highly recommended that WordNet source files are loaded into Oscova before training. WordNet being a lexical database enchances Oscova's capability of find semantic relatedness between words.
WordNet® is a registered trademark of Princeton University.
Loading Files
To load WordNet lexical database files into Oscova you can make use of the AddDataSource
and AddIndexSource
methods available on the WordNet
property. Each file must be passed in via a StreamReader
and the appropriate PartOfSpeech
addressed by the files must be specified.
There are 4 main parts of speech for which we'll need to load data.
- Adjective
- Adverb
- Noun
- Verb
The following are the names of database files that need to be loaded into the WordNet engine.
Data: Added via AddDataSource
method.
- data.adj
- data.adv
- data.noun
- data.verb
Index: Added via AddIndexSource
method.
- index.adj
- index.adv
- index.noun
- index.verb
Example
var directory = Directory.GetCurrentDirectory();
var wordNet = new WordNetEngine();
Console.WriteLine("Loading database...");
wordNet.LoadFromDirectory(directory);
Console.WriteLine("Load completed.");
...
bot.Trainer.StartTraining();
Or (Depending on your platform)
var bot = new OscovaBot();
var wordNet = bot.Language.WordNet;
const string directory = @"D:\WordNet\dict";
//Data
wordNet.AddDataSource(new StreamReader(Path.Combine(directory, "data.adj")), PartOfSpeech.Adjective);
wordNet.AddDataSource(new StreamReader(Path.Combine(directory, "data.adv")), PartOfSpeech.Adverb);
wordNet.AddDataSource(new StreamReader(Path.Combine(directory, "data.noun")), PartOfSpeech.Noun);
wordNet.AddDataSource(new StreamReader(Path.Combine(directory, "data.verb")), PartOfSpeech.Verb);
//Indices
wordNet.AddIndexSource(new StreamReader(Path.Combine(directory, "index.adj")), PartOfSpeech.Adjective);
wordNet.AddIndexSource(new StreamReader(Path.Combine(directory, "index.adv")), PartOfSpeech.Adverb);
wordNet.AddIndexSource(new StreamReader(Path.Combine(directory, "index.noun")), PartOfSpeech.Noun);
wordNet.AddIndexSource(new StreamReader(Path.Combine(directory, "index.verb")), PartOfSpeech.Verb);
//Important
wordNet.Load();
...
bot.Trainer.StartTraining();
Note
Loading of WordNet files may take a couple of seconds.
After adding the source files, you must call the WordNet.Load()
method. Once the load completes, Oscova will automatically detect the change and will start using WordNet to find lexical relations between words and their senses while scoring intents.