public void TestBuild()
        {

            String LF = System.Environment.NewLine;
            String input = "oneword" + LF + "twoword" + LF + "threeword";
            PlainTextDictionary ptd = new PlainTextDictionary( new MemoryStream( System.Text.Encoding.UTF8.GetBytes(input)) );
            RAMDirectory ramDir = new RAMDirectory();
            SpellChecker.Net.Search.Spell.SpellChecker spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(ramDir);
            spellChecker.IndexDictionary(ptd);
            String[] similar = spellChecker.SuggestSimilar("treeword", 2);
            Assert.AreEqual(2, similar.Length);
            Assert.AreEqual(similar[0], "threeword");
            Assert.AreEqual(similar[1], "twoword");
        }
Ejemplo n.º 2
0
 public static void Build(string dictionaryPath, string indexPath)
 {
     var di = CreateTargetFolder(indexPath);
     using (var file = File.Open(dictionaryPath, FileMode.Open, FileAccess.Read))
     {
         var dict = new PlainTextDictionary(file);
         using (var staticSpellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(FSDirectory.Open(di)))
         {
             try
             {
                 staticSpellChecker.IndexDictionary(dict);
             }
             catch (Exception e)
             {
                 Console.WriteLine(e.Message);
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void  InitBlock(PlainTextDictionary enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Ejemplo n.º 4
0
 public FileIterator(PlainTextDictionary enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
Ejemplo n.º 5
0
 private void  InitBlock(PlainTextDictionary enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Ejemplo n.º 6
0
 public FileIterator(PlainTextDictionary enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }