示例#1
0
        private void Addwords(IndexReader r, SpellChecker sc, string field)
        {
            long time = J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond; // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results

            sc.IndexDictionary(new LuceneDictionary(r, field), NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
            time = (J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond) - time; // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results
            //System.out.println("time to build " + field + ": " + time);
        }
示例#2
0
        private void Addwords(IndexReader r, SpellChecker sc, string field)
        {
            long time = Environment.TickCount;

            sc.IndexDictionary(new LuceneDictionary(r, field), NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
            time = Environment.TickCount - time;
            //System.out.println("time to build " + field + ": " + time);
        }
 public void TestBuild()
 {
     string LF = Environment.NewLine;
     string input = "oneword" + LF + "twoword" + LF + "threeword";
     PlainTextDictionary ptd = new PlainTextDictionary(new StringReader(input));
     Store.Directory ramDir = NewDirectory();
     SpellChecker spellChecker = new SpellChecker(ramDir);
     spellChecker.IndexDictionary(ptd, NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
     string[] similar = spellChecker.SuggestSimilar("treeword", 2);
     assertEquals(2, similar.Length);
     assertEquals(similar[0], "threeword");
     assertEquals(similar[1], "oneword");
     spellChecker.Dispose();
     ramDir.Dispose();
 }
示例#4
0
        public void TestSpellchecker()
        {
            Directory    dir = NewDirectory();
            SpellChecker sc  = new SpellChecker(dir);

            indexReader = DirectoryReader.Open(store);
            sc.IndexDictionary(new LuceneDictionary(indexReader, "contents"), NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
            string[] suggestions = sc.SuggestSimilar("Tam", 1);
            assertEquals(1, suggestions.Length);
            assertEquals("Tom", suggestions[0]);
            suggestions = sc.SuggestSimilar("Jarry", 1);
            assertEquals(1, suggestions.Length);
            assertEquals("Jerry", suggestions[0]);
            indexReader.Dispose();
            sc.Dispose();
            dir.Dispose();
        }
        public void TestBuild()
        {
            string LF               = Environment.NewLine;
            string input            = "oneword" + LF + "twoword" + LF + "threeword";
            PlainTextDictionary ptd = new PlainTextDictionary(new StringReader(input));

            Store.Directory ramDir       = NewDirectory();
            SpellChecker    spellChecker = new SpellChecker(ramDir);

            spellChecker.IndexDictionary(ptd, NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
            string[] similar = spellChecker.SuggestSimilar("treeword", 2);
            assertEquals(2, similar.Length);
            assertEquals(similar[0], "threeword");
            assertEquals(similar[1], "oneword");
            spellChecker.Dispose();
            ramDir.Dispose();
        }
 public void TestSpellchecker()
 {
     Directory dir = NewDirectory();
     SpellChecker sc = new SpellChecker(dir);
     indexReader = DirectoryReader.Open(store);
     sc.IndexDictionary(new LuceneDictionary(indexReader, "contents"), NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
     string[] suggestions = sc.SuggestSimilar("Tam", 1);
     assertEquals(1, suggestions.Length);
     assertEquals("Tom", suggestions[0]);
     suggestions = sc.SuggestSimilar("Jarry", 1);
     assertEquals(1, suggestions.Length);
     assertEquals("Jerry", suggestions[0]);
     indexReader.Dispose();
     sc.Dispose();
     dir.Dispose();
 }
 private void Addwords(IndexReader r, SpellChecker sc, string field)
 {
     long time = Environment.TickCount;
     sc.IndexDictionary(new LuceneDictionary(r, field), NewIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
     time = Environment.TickCount - time;
     //System.out.println("time to build " + field + ": " + time);
 }