// Add the plugins actions and data source public InitializeResult Initialize(PluginEnvironment env, Assembly assembly, IMessageReceiver receiver) { // Data files contained in [datadrectory]/parser string morphodir = env.GetConfigDirectory("datadirectory") + Path.DirectorySeparatorChar + "morpho" + Path.DirectorySeparatorChar; MemcachedClient cache = MemcacheSource.DefaultClient(); GivenNames names = new GivenNames(morphodir, cache); return(InitializeResult.Success()); }
public InitializeResult InitializeLocal(PluginEnvironment env, IMessageReceiver receiver) { // Data files contained in [datadrectory]/wordnet string basedir = env.GetConfigDirectory("datadirectory") + Path.DirectorySeparatorChar + "wordnet" + Path.DirectorySeparatorChar; MemcachedClient cache = MemcacheSource.DefaultClient(); nounIndexSource = new BackedMemcachedSource <Index>(new IndexFile(basedir, WordNetAccess.PartOfSpeech.Noun), "WN:I:N:", cache); verbIndexSource = new BackedMemcachedSource <Index>(new IndexFile(basedir, WordNetAccess.PartOfSpeech.Verb), "WN:I:V:", cache); adjIndexSource = new BackedMemcachedSource <Index>(new IndexFile(basedir, WordNetAccess.PartOfSpeech.Adj), "WN:I:A:", cache); advIndexSource = new BackedMemcachedSource <Index>(new IndexFile(basedir, WordNetAccess.PartOfSpeech.Adv), "WN:I:R:", cache); if (!advIndexSource.TestMemcached(10, 10)) { Console.Out.WriteLine("Loading nouns into Memcached"); nounIndexSource.LoadIntoMemcached(); Console.Out.WriteLine("Loading verbs into Memcached"); verbIndexSource.LoadIntoMemcached(); Console.Out.WriteLine("Loading adjectives into Memcached"); adjIndexSource.LoadIntoMemcached(); Console.Out.WriteLine("Loading adverbs into Memcached"); advIndexSource.LoadIntoMemcached(); } nounOffsetsSource = new MapDataSource <string, Index, long[]>(nounIndexSource, IndexFile.ExtractOffsets, null); verbOffsetsSource = new MapDataSource <string, Index, long[]>(verbIndexSource, IndexFile.ExtractOffsets, null); adjOffsetsSource = new MapDataSource <string, Index, long[]>(adjIndexSource, IndexFile.ExtractOffsets, null); advOffsetsSource = new MapDataSource <string, Index, long[]>(advIndexSource, IndexFile.ExtractOffsets, null); env.SetDataSource <string, long[]>(WordNetAccess.NounIndexSourceName, nounOffsetsSource); env.SetDataSource <string, long[]>(WordNetAccess.VerbIndexSourceName, verbOffsetsSource); env.SetDataSource <string, long[]>(WordNetAccess.AdjIndexSourceName, adjOffsetsSource); env.SetDataSource <string, long[]>(WordNetAccess.AdvIndexSourceName, advOffsetsSource); nounDefinitionSource = new DefinitionFile(basedir, WordNetAccess.PartOfSpeech.Noun); verbDefinitionSource = new DefinitionFile(basedir, WordNetAccess.PartOfSpeech.Verb); adjDefinitionSource = new DefinitionFile(basedir, WordNetAccess.PartOfSpeech.Adv); advDefinitionSource = new DefinitionFile(basedir, WordNetAccess.PartOfSpeech.Adv); env.SetDataSource <long, WordNetDefinition>(WordNetAccess.NounDefinitionSourceName, nounDefinitionSource); env.SetDataSource <long, WordNetDefinition>(WordNetAccess.VerbDefinitionSourceName, verbDefinitionSource); env.SetDataSource <long, WordNetDefinition>(WordNetAccess.AdjDefinitionSourceName, adjDefinitionSource); env.SetDataSource <long, WordNetDefinition>(WordNetAccess.AdvDefinitionSourceName, advDefinitionSource); fileTools = new FileWordNetTools(env.GetConfigDirectory("datadirectory") + Path.DirectorySeparatorChar + "wordnet" + Path.DirectorySeparatorChar); return(InitializeResult.Success()); }
public WordFrequencies(string baseDirectory) { this.baseDirectory = baseDirectory; WordFrequencyFileSource wordSource = new WordFrequencyFileSource(baseDirectory + wordFilename); WordFrequencyFileSource stemSource = new WordFrequencyFileSource(baseDirectory + stemFilename); this.wordCache = new BackedMemcachedSource <ThreeTuple <uint, double, double> >(wordSource, wfPrefix, MemcacheSource.DefaultClient()); this.stemCache = new BackedMemcachedSource <ThreeTuple <uint, double, double> >(stemSource, sfPrefix, MemcacheSource.DefaultClient()); }