lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris.Hill <>
Subject Re: Use of synonyms or thesaurus
Date Tue, 07 Nov 2017 17:19:43 GMT
Thanks for that - I have updated Lucene.Net to latest Beta, and worked through the changes
in code so my example is still functioning OK.

Where can I find an example please of using the SynonymMap and SynonymFilter?

I have the following so far (I am just testing) :

            String base1 = "lawnmower";
            String syn1 = "lawn mower";
            String base2 = "spanner";
            String syn2 = "wrench";

            SynonymMap.Builder sb = new SynonymMap.Builder(true);
            sb.Add(new CharsRef(base1), new CharsRef(syn1), true);
            sb.Add(new CharsRef(base2), new CharsRef(syn2), true);
            SynonymMap smap = sb.Build();

            TextReader reader = File.OpenText(@"D:\test.txt");
            string line;
            while ((line = reader.ReadLine()) != null)

            Tokenizer source = new ClassicTokenizer(Version.LUCENE_48, reader);
            TokenStream filter = new StandardFilter(Version.LUCENE_48, source);
            SynonymFilter synFilter = new SynonymFilter(filter, smap, true);

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message