You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/04/01 01:08:55 UTC
[02/62] [abbrv] lucenenet git commit: Deleted obsolete Contrib folder
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/SpellChecker/Spell/SpellChecker.cs
----------------------------------------------------------------------
diff --git a/src/contrib/SpellChecker/Spell/SpellChecker.cs b/src/contrib/SpellChecker/Spell/SpellChecker.cs
deleted file mode 100644
index efa390e..0000000
--- a/src/contrib/SpellChecker/Spell/SpellChecker.cs
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-using System.Collections.Generic;
-
-namespace SpellChecker.Net.Search.Spell
-{
- using System;
-
- using Lucene.Net.Search;
- using Lucene.Net.Store;
- using BooleanClause = Lucene.Net.Search.BooleanClause;
- using BooleanQuery = Lucene.Net.Search.BooleanQuery;
- using Directory = Lucene.Net.Store.Directory;
- using Document = Lucene.Net.Documents.Document;
- using Field = Lucene.Net.Documents.Field;
- using IndexReader = Lucene.Net.Index.IndexReader;
- using IndexSearcher = Lucene.Net.Search.IndexSearcher;
- using IndexWriter = Lucene.Net.Index.IndexWriter;
- using Query = Lucene.Net.Search.Query;
- using Term = Lucene.Net.Index.Term;
- using TermQuery = Lucene.Net.Search.TermQuery;
- using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
-
-
- /// <summary> <p>
- /// Spell Checker class (Main class) <br/>
- /// (initially inspired by the David Spencer code).
- /// </p>
- ///
- /// <p>Example Usage:</p>
- ///
- /// <pre>
- /// SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
- /// // To index a field of a user index:
- /// spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field));
- /// // To index a file containing words:
- /// spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")));
- /// String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);
- /// </pre>
- ///
- /// </summary>
- /// <author> Nicolas Maisonneuve
- /// </author>
- /// <version> 1.0
- /// </version>
- public class SpellChecker : IDisposable
- {
- /// <summary> Field name for each word in the ngram index.</summary>
- public const System.String F_WORD = "word";
- private readonly Term F_WORD_TERM = new Term(F_WORD);
-
- /// <summary> the spell index</summary>
- internal Directory spellindex;
-
- /// <summary> Boost value for start and end grams</summary>
- private const float bStart = 2.0f;
- private const float bEnd = 1.0f;
-
- // don't use this searcher directly - see #swapSearcher()
- private IndexSearcher searcher;
-
- /// <summary>
- /// this locks all modifications to the current searcher.
- /// </summary>
- private static readonly System.Object searcherLock = new System.Object();
-
- /*
- * this lock synchronizes all possible modifications to the
- * current index directory. It should not be possible to try modifying
- * the same index concurrently. Note: Do not acquire the searcher lock
- * before acquiring this lock!
- */
- private static readonly System.Object modifyCurrentIndexLock = new System.Object();
- private volatile bool closed = false;
-
- internal float minScore = 0.5f; //LUCENENET-359 Spellchecker accuracy gets overwritten
-
- private StringDistance sd;
-
- /// <summary>
- /// Use the given directory as a spell checker index. The directory
- /// is created if it doesn't exist yet.
- /// </summary>
- /// <param name="spellIndex">the spell index directory</param>
- /// <param name="sd">the <see cref="StringDistance"/> measurement to use </param>
- public SpellChecker(Directory spellIndex, StringDistance sd)
- {
- this.SetSpellIndex(spellIndex);
- this.setStringDistance(sd);
- }
-
- /// <summary>
- /// Use the given directory as a spell checker index with a
- /// <see cref="LevenshteinDistance"/> as the default <see cref="StringDistance"/>. The
- /// directory is created if it doesn't exist yet.
- /// </summary>
- /// <param name="spellIndex">the spell index directory</param>
- public SpellChecker(Directory spellIndex)
- : this(spellIndex, new LevenshteinDistance())
- { }
-
- /// <summary>
- /// Use a different index as the spell checker index or re-open
- /// the existing index if <c>spellIndex</c> is the same value
- /// as given in the constructor.
- /// </summary>
- /// <param name="spellIndexDir">spellIndexDir the spell directory to use </param>
- /// <throws>AlreadyClosedException if the Spellchecker is already closed</throws>
- /// <throws>IOException if spellchecker can not open the directory</throws>
- virtual public void SetSpellIndex(Directory spellIndexDir)
- {
- // this could be the same directory as the current spellIndex
- // modifications to the directory should be synchronized
- lock (modifyCurrentIndexLock)
- {
- EnsureOpen();
- if (!IndexReader.IndexExists(spellIndexDir))
- {
- var writer = new IndexWriter(spellIndexDir, null, true,
- IndexWriter.MaxFieldLength.UNLIMITED);
- writer.Close();
- }
- SwapSearcher(spellIndexDir);
- }
- }
-
- /// <summary>
- /// Sets the <see cref="StringDistance"/> implementation for this
- /// <see cref="SpellChecker"/> instance.
- /// </summary>
- /// <param name="sd">the <see cref="StringDistance"/> implementation for this
- /// <see cref="SpellChecker"/> instance.</param>
- public void setStringDistance(StringDistance sd)
- {
- this.sd = sd;
- }
-
- /// <summary>
- /// Returns the <see cref="StringDistance"/> instance used by this
- /// <see cref="SpellChecker"/> instance.
- /// </summary>
- /// <returns>
- /// Returns the <see cref="StringDistance"/> instance used by this
- /// <see cref="SpellChecker"/> instance.
- /// </returns>
- public StringDistance GetStringDistance()
- {
- return sd;
- }
-
-
- /// <summary> Set the accuracy 0 < min < 1; default 0.5</summary>
- virtual public void SetAccuracy(float minScore)
- {
- this.minScore = minScore;
- }
-
- /// <summary> Suggest similar words</summary>
- /// <param name="word">String the word you want a spell check done on
- /// </param>
- /// <param name="num_sug">int the number of suggest words
- /// </param>
- /// <throws> IOException </throws>
- /// <returns> String[]
- /// </returns>
- public virtual System.String[] SuggestSimilar(System.String word, int num_sug)
- {
- return this.SuggestSimilar(word, num_sug, null, null, false);
- }
-
-
- /// <summary> Suggest similar words (restricted or not to a field of a user index)</summary>
- /// <param name="word">String the word you want a spell check done on
- /// </param>
- /// <param name="numSug">int the number of suggest words
- /// </param>
- /// <param name="ir">the indexReader of the user index (can be null see field param)
- /// </param>
- /// <param name="field">String the field of the user index: if field is not null, the suggested
- /// words are restricted to the words present in this field.
- /// </param>
- /// <param name="morePopular">boolean return only the suggest words that are more frequent than the searched word
- /// (only if restricted mode = (indexReader!=null and field!=null)
- /// </param>
- /// <throws> IOException </throws>
- /// <returns> String[] the sorted list of the suggest words with this 2 criteria:
- /// first criteria: the edit distance, second criteria (only if restricted mode): the popularity
- /// of the suggest words in the field of the user index
- /// </returns>
- public virtual System.String[] SuggestSimilar(System.String word, int numSug, IndexReader ir, System.String field, bool morePopular)
- { // obtainSearcher calls ensureOpen
- IndexSearcher indexSearcher = ObtainSearcher();
- try
- {
- float min = this.minScore;
- int lengthWord = word.Length;
-
- int freq = (ir != null && field != null) ? ir.DocFreq(new Term(field, word)) : 0;
- int goalFreq = (morePopular && ir != null && field != null) ? freq : 0;
- // if the word exists in the real index and we don't care for word frequency, return the word itself
- if (!morePopular && freq > 0)
- {
- return new String[] { word };
- }
-
- var query = new BooleanQuery();
- String[] grams;
- String key;
-
- var alreadySeen = new HashSet<string>();
- for (var ng = GetMin(lengthWord); ng <= GetMax(lengthWord); ng++)
- {
- key = "gram" + ng; // form key
-
- grams = FormGrams(word, ng); // form word into ngrams (allow dups too)
-
- if (grams.Length == 0)
- {
- continue; // hmm
- }
-
- if (bStart > 0)
- { // should we boost prefixes?
- Add(query, "start" + ng, grams[0], bStart); // matches start of word
-
- }
- if (bEnd > 0)
- { // should we boost suffixes
- Add(query, "end" + ng, grams[grams.Length - 1], bEnd); // matches end of word
-
- }
- for (int i = 0; i < grams.Length; i++)
- {
- Add(query, key, grams[i]);
- }
- }
-
- int maxHits = 10 * numSug;
-
- // System.out.println("Q: " + query);
- ScoreDoc[] hits = indexSearcher.Search(query, null, maxHits).ScoreDocs;
- // System.out.println("HITS: " + hits.length());
- SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
-
- // go thru more than 'maxr' matches in case the distance filter triggers
- int stop = Math.Min(hits.Length, maxHits);
- SuggestWord sugWord = new SuggestWord();
- for (int i = 0; i < stop; i++)
- {
- sugWord.termString = indexSearcher.Doc(hits[i].Doc).Get(F_WORD); // get orig word
-
- // don't suggest a word for itself, that would be silly
- if (sugWord.termString.Equals(word))
- {
- continue;
- }
-
- // edit distance
- sugWord.score = sd.GetDistance(word, sugWord.termString);
- if (sugWord.score < min)
- {
- continue;
- }
-
- if (ir != null && field != null)
- { // use the user index
- sugWord.freq = ir.DocFreq(new Term(field, sugWord.termString)); // freq in the index
- // don't suggest a word that is not present in the field
- if ((morePopular && goalFreq > sugWord.freq) || sugWord.freq < 1)
- {
- continue;
- }
- }
-
- if (alreadySeen.Add(sugWord.termString) == false) // we already seen this word, no point returning it twice
- continue;
-
- sugQueue.InsertWithOverflow(sugWord);
- if (sugQueue.Size() == numSug)
- {
- // if queue full, maintain the minScore score
- min = ((SuggestWord)sugQueue.Top()).score;
- }
- sugWord = new SuggestWord();
- }
-
- // convert to array string
- String[] list = new String[sugQueue.Size()];
- for (int i = sugQueue.Size() - 1; i >= 0; i--)
- {
- list[i] = ((SuggestWord)sugQueue.Pop()).termString;
- }
-
- return list;
- }
- finally
- {
- ReleaseSearcher(indexSearcher);
- }
-
- }
-
-
- /// <summary> Add a clause to a boolean query.</summary>
- private static void Add(BooleanQuery q, System.String k, System.String v, float boost)
- {
- Query tq = new TermQuery(new Term(k, v));
- tq.Boost = boost;
- q.Add(new BooleanClause(tq, Occur.SHOULD));
- }
-
-
- /// <summary> Add a clause to a boolean query.</summary>
- private static void Add(BooleanQuery q, System.String k, System.String v)
- {
- q.Add(new BooleanClause(new TermQuery(new Term(k, v)), Occur.SHOULD));
- }
-
-
- /// <summary> Form all ngrams for a given word.</summary>
- /// <param name="text">the word to parse
- /// </param>
- /// <param name="ng">the ngram length e.g. 3
- /// </param>
- /// <returns> an array of all ngrams in the word and note that duplicates are not removed
- /// </returns>
- private static System.String[] FormGrams(System.String text, int ng)
- {
- int len = text.Length;
- System.String[] res = new System.String[len - ng + 1];
- for (int i = 0; i < len - ng + 1; i++)
- {
- res[i] = text.Substring(i, (i + ng) - (i));
- }
- return res;
- }
-
- /// <summary>
- /// Removes all terms from the spell check index.
- /// </summary>
- public virtual void ClearIndex()
- {
- lock (modifyCurrentIndexLock)
- {
- EnsureOpen();
- Directory dir = this.spellindex;
- IndexWriter writer = new IndexWriter(dir, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
- writer.Close();
- SwapSearcher(dir);
- }
- }
-
-
- /// <summary> Check whether the word exists in the index.</summary>
- /// <param name="word">String
- /// </param>
- /// <throws> IOException </throws>
- /// <returns> true iff the word exists in the index
- /// </returns>
- public virtual bool Exist(System.String word)
- {
- // obtainSearcher calls ensureOpen
- IndexSearcher indexSearcher = ObtainSearcher();
- try
- {
- return indexSearcher.DocFreq(F_WORD_TERM.CreateTerm(word)) > 0;
- }
- finally
- {
- ReleaseSearcher(indexSearcher);
- }
- }
-
-
- /// <summary> Index a Dictionary</summary>
- /// <param name="dict">the dictionary to index</param>
- /// <param name="mergeFactor">mergeFactor to use when indexing</param>
- /// <param name="ramMB">the max amount or memory in MB to use</param>
- /// <throws> IOException </throws>
- /// <throws>AlreadyClosedException if the Spellchecker is already closed</throws>
- public virtual void IndexDictionary(IDictionary dict, int mergeFactor, int ramMB)
- {
- lock (modifyCurrentIndexLock)
- {
- EnsureOpen();
- Directory dir = this.spellindex;
- IndexWriter writer = new IndexWriter(spellindex, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
- writer.MergeFactor = mergeFactor;
- writer.SetMaxBufferedDocs(ramMB);
-
- System.Collections.IEnumerator iter = dict.GetWordsIterator();
- while (iter.MoveNext())
- {
- System.String word = (System.String)iter.Current;
-
- int len = word.Length;
- if (len < 3)
- {
- continue; // too short we bail but "too long" is fine...
- }
-
- if (this.Exist(word))
- {
- // if the word already exist in the gramindex
- continue;
- }
-
- // ok index the word
- Document doc = CreateDocument(word, GetMin(len), GetMax(len));
- writer.AddDocument(doc);
- }
- // close writer
- writer.Optimize();
- writer.Close();
- // also re-open the spell index to see our own changes when the next suggestion
- // is fetched:
- SwapSearcher(dir);
- }
- }
-
- /// <summary>
- /// Indexes the data from the given <see cref="IDictionary"/>.
- /// </summary>
- /// <param name="dict">dict the dictionary to index</param>
- public void IndexDictionary(IDictionary dict)
- {
- IndexDictionary(dict, 300, 10);
- }
-
- private int GetMin(int l)
- {
- if (l > 5)
- {
- return 3;
- }
- if (l == 5)
- {
- return 2;
- }
- return 1;
- }
-
-
- private int GetMax(int l)
- {
- if (l > 5)
- {
- return 4;
- }
- if (l == 5)
- {
- return 3;
- }
- return 2;
- }
-
-
- private static Document CreateDocument(System.String text, int ng1, int ng2)
- {
- Document doc = new Document();
- doc.Add(new Field(F_WORD, text, Field.Store.YES, Field.Index.NOT_ANALYZED)); // orig term
- AddGram(text, doc, ng1, ng2);
- return doc;
- }
-
-
- private static void AddGram(System.String text, Document doc, int ng1, int ng2)
- {
- int len = text.Length;
- for (int ng = ng1; ng <= ng2; ng++)
- {
- System.String key = "gram" + ng;
- System.String end = null;
- for (int i = 0; i < len - ng + 1; i++)
- {
- System.String gram = text.Substring(i, (i + ng) - (i));
- doc.Add(new Field(key, gram, Field.Store.NO, Field.Index.NOT_ANALYZED));
- if (i == 0)
- {
- doc.Add(new Field("start" + ng, gram, Field.Store.NO, Field.Index.NOT_ANALYZED));
- }
- end = gram;
- }
- if (end != null)
- {
- // may not be present if len==ng1
- doc.Add(new Field("end" + ng, end, Field.Store.NO, Field.Index.NOT_ANALYZED));
- }
- }
- }
-
- private IndexSearcher ObtainSearcher()
- {
- lock (searcherLock)
- {
- EnsureOpen();
- searcher.IndexReader.IncRef();
- return searcher;
- }
- }
-
- private void ReleaseSearcher(IndexSearcher aSearcher)
- {
- // don't check if open - always decRef
- // don't decrement the private searcher - could have been swapped
- aSearcher.IndexReader.DecRef();
- }
-
- private void EnsureOpen()
- {
- if (closed)
- {
- throw new AlreadyClosedException("Spellchecker has been closed");
- }
- }
-
- public void Close()
- {
- lock (searcherLock)
- {
- EnsureOpen();
- closed = true;
- if (searcher != null)
- {
- searcher.Close();
- }
- searcher = null;
- }
- }
-
- private void SwapSearcher(Directory dir)
- {
- /*
- * opening a searcher is possibly very expensive.
- * We rather close it again if the Spellchecker was closed during
- * this operation than block access to the current searcher while opening.
- */
- IndexSearcher indexSearcher = CreateSearcher(dir);
- lock (searcherLock)
- {
- if (closed)
- {
- indexSearcher.Close();
- throw new AlreadyClosedException("Spellchecker has been closed");
- }
- if (searcher != null)
- {
- searcher.Close();
- }
- // set the spellindex in the sync block - ensure consistency.
- searcher = indexSearcher;
- this.spellindex = dir;
- }
- }
-
- /// <summary>
- /// Creates a new read-only IndexSearcher (for testing purposes)
- /// </summary>
- /// <param name="dir">dir the directory used to open the searcher</param>
- /// <returns>a new read-only IndexSearcher. (throws IOException f there is a low-level IO error)</returns>
- public virtual IndexSearcher CreateSearcher(Directory dir)
- {
- return new IndexSearcher(dir, true);
- }
-
- /// <summary>
- /// Returns <c>true</c> if and only if the <see cref="SpellChecker"/> is
- /// closed, otherwise <c>false</c>.
- /// </summary>
- /// <returns><c>true</c> if and only if the <see cref="SpellChecker"/> is
- /// closed, otherwise <c>false</c>.
- ///</returns>
- bool IsClosed()
- {
- return closed;
- }
-
- ~SpellChecker()
- {
- this.Dispose(false);
- }
-
- public void Dispose()
- {
- this.Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposeOfManagedResources)
- {
- if (disposeOfManagedResources)
- {
- if (!this.closed)
- this.Close();
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/SpellChecker/Spell/StringDistance.cs
----------------------------------------------------------------------
diff --git a/src/contrib/SpellChecker/Spell/StringDistance.cs b/src/contrib/SpellChecker/Spell/StringDistance.cs
deleted file mode 100644
index b836c99..0000000
--- a/src/contrib/SpellChecker/Spell/StringDistance.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-namespace SpellChecker.Net.Search.Spell
-{
- using System;
-
- /// <summary>
- /// Interface for string distances.
- /// </summary>
- public interface StringDistance
- {
- /// <summary>
- /// Returns a float between 0 and 1 based on how similar the specified strings are to one another.
- /// Returning a value of 1 means the specified strings are identical and 0 means the
- /// string are maximally different.
- /// </summary>
- /// <param name="s1">The first string.</param>
- /// <param name="s2">The second string.</param>
- /// <returns>a float between 0 and 1 based on how similar the specified strings are to one another.</returns>
- float GetDistance(String s1, String s2);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/SpellChecker/Spell/SuggestWord.cs
----------------------------------------------------------------------
diff --git a/src/contrib/SpellChecker/Spell/SuggestWord.cs b/src/contrib/SpellChecker/Spell/SuggestWord.cs
deleted file mode 100644
index 54840b2..0000000
--- a/src/contrib/SpellChecker/Spell/SuggestWord.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace SpellChecker.Net.Search.Spell
-{
-
- /// <summary> SuggestWord Class, used in suggestSimilar method in SpellChecker class.
- ///
- /// </summary>
- /// <author> Nicolas Maisonneuve
- /// </author>
- sealed class SuggestWord
- {
- /// <summary> the score of the word</summary>
- public float score;
-
- /// <summary> The freq of the word</summary>
- public int freq;
-
- /// <summary> the suggested word</summary>
- public System.String termString;
-
- public int CompareTo(SuggestWord a)
- {
- //first criteria: the edit distance
- if (score > a.score)
- {
- return 1;
- }
- if (score < a.score)
- {
- return - 1;
- }
-
- //second criteria (if first criteria is equal): the popularity
- if (freq > a.freq)
- {
- return 1;
- }
-
- if (freq < a.freq)
- {
- return - 1;
- }
-
- return 0;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/SpellChecker/Spell/SuggestWordQueue.cs
----------------------------------------------------------------------
diff --git a/src/contrib/SpellChecker/Spell/SuggestWordQueue.cs b/src/contrib/SpellChecker/Spell/SuggestWordQueue.cs
deleted file mode 100644
index 7ae17ec..0000000
--- a/src/contrib/SpellChecker/Spell/SuggestWordQueue.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-namespace SpellChecker.Net.Search.Spell
-{
- using PriorityQueue = Lucene.Net.Util.PriorityQueue<SuggestWord>;
-
- sealed class SuggestWordQueue : PriorityQueue
- {
-
- internal SuggestWordQueue(int size)
- {
- Initialize(size);
- }
-
- override public bool LessThan(SuggestWord a, SuggestWord b)
- {
- var val = a.CompareTo(b);
- return val < 0;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/SpellChecker/Spell/TRStringDistance.cs
----------------------------------------------------------------------
diff --git a/src/contrib/SpellChecker/Spell/TRStringDistance.cs b/src/contrib/SpellChecker/Spell/TRStringDistance.cs
deleted file mode 100644
index 79b2314..0000000
--- a/src/contrib/SpellChecker/Spell/TRStringDistance.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-namespace SpellChecker.Net.Search.Spell
-{
-
- /// <summary> Edit distance class</summary>
- public class TRStringDistance
- {
-
- internal char[] sa;
- internal int n;
- internal int[][][] cache = new int[30][][];
-
-
- /// <summary> Optimized to run a bit faster than the static getDistance().
- /// In one benchmark times were 5.3sec using ctr vs 8.5sec w/ static method, thus 37% faster.
- /// </summary>
- public TRStringDistance(System.String target)
- {
- sa = target.ToCharArray();
- n = sa.Length;
- }
-
-
- //***************************
- // Compute Levenshtein distance
- //***************************
- public int GetDistance(System.String other)
- {
- int[][] d; // matrix
-
- // Step 1
- char[] ta = other.ToCharArray();
- int m = ta.Length;
- if (n == 0)
- {
- return m;
- }
- if (m == 0)
- {
- return n;
- }
-
- if (m >= cache.Length)
- {
- d = Form(n, m);
- }
- else if (cache[m] != null)
- {
- d = cache[m];
- }
- else
- {
- d = cache[m] = Form(n, m);
-
- // Step 3
- }
- for (int i = 1; i <= n; i++)
- {
- char s_i = sa[i - 1];
-
- // Step 4
-
- for (int j = 1; j <= m; j++)
- {
- char t_j = ta[j - 1];
-
- // Step 5
-
- int cost = s_i == t_j ? 0 : 1;
- d[i][j] = Min3(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
- }
- }
-
- // Step 7
- return d[n][m];
- }
-
-
- /// <summary> </summary>
- private static int[][] Form(int n, int m)
- {
- int[][] d = new int[n + 1][];
- for (int i = 0; i < n + 1; i++)
- {
- d[i] = new int[m + 1];
- }
- // Step 2
-
- for (int i = 0; i <= n; i++)
- {
- d[i][0] = i;
- }
- for (int j = 0; j <= m; j++)
- {
- d[0][j] = j;
- }
- return d;
- }
-
-
- //**************************
- // Get minimum of three values
- //**************************
- private static int Min3(int a, int b, int c)
- {
- int mi = a;
- if (b < mi)
- {
- mi = b;
- }
- if (c < mi)
- {
- mi = c;
- }
- return mi;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/ABOUT.txt
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/ABOUT.txt b/src/contrib/WordNet/ABOUT.txt
deleted file mode 100644
index ada5e7a..0000000
--- a/src/contrib/WordNet/ABOUT.txt
+++ /dev/null
@@ -1 +0,0 @@
-WordNet.Net is a port of Java WordNet to C#. The port from Java to C# of version 2.0.0 is done by George Aroush. To contact George Aroush please visit http://www.aroush.net/
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/HISTORY.txt
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/HISTORY.txt b/src/contrib/WordNet/HISTORY.txt
deleted file mode 100644
index 0e3e253..0000000
--- a/src/contrib/WordNet/HISTORY.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-WordNet.Net History
--------------------
-
-
-01Feb07:
- - Release: WordNet.Net.2.0.0 build 001
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/Package.html
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/Package.html b/src/contrib/WordNet/Package.html
deleted file mode 100644
index 4120597..0000000
--- a/src/contrib/WordNet/Package.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-
-<html>
- <head>
- <title>WordNet Lucene.Net Synonyms Integration</title>
- </head>
- <body>
- This package uses synonyms defined by <a href="http:/www.cogsci.princeton.edu/~wn/">
- WordNet</a> to build a Lucene.Net index storing them, which in turn can be
- used for query expansion. You normally run {@link WordNet.Net.Syns2Index} once
- to build the query index/"database", and then call {@link
- WordNet.Net.SynExpand#Expand SynExpand.Expand(...)} to expand a query.
- <p>
- <h3>
- Instructions
- </h3>
- <ol>
- <li>
- Download the <a href="http://wordnet.princeton.edu/3.0/WNprolog-3.0.tar.gz">WordNet
- prolog database</a>
- , gunzip, untar etc.
- <li>
- Invoke Syn2Index as appropriate to build a synonym index. It'll take 2
- arguments, the path to wn_s.pl from that WordNet download, and the index name.
- <li>
- Update your UI so that as appropriate you call SynExpand.Expand(...) to expand
- user queries with synonyms.</li>
- </ol>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/README.txt
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/README.txt b/src/contrib/WordNet/README.txt
deleted file mode 100644
index ea78e07..0000000
--- a/src/contrib/WordNet/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-As of 2002-11-13 WordNet Lucene contribution contains a single Java/C# class:
- WordNet.Net.Syns2Index.
-
-This class creates a Lucene index with synonyms for English words from
-a Prolog file, which is a part of WordNet database.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynExpand/App.ico
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynExpand/App.ico b/src/contrib/WordNet/SynExpand/App.ico
deleted file mode 100644
index 3a5525f..0000000
Binary files a/src/contrib/WordNet/SynExpand/App.ico and /dev/null differ
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynExpand/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynExpand/AssemblyInfo.cs b/src/contrib/WordNet/SynExpand/AssemblyInfo.cs
deleted file mode 100644
index f52e363..0000000
--- a/src/contrib/WordNet/SynExpand/AssemblyInfo.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Security;
-
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("Lucene.Net.WordNet.SynExpand")]
-[assembly: AssemblyDescription("The Apache Software Foundation Lucene.Net a full-text search engine library")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("The Apache Software Foundation")]
-[assembly: AssemblyProduct("Lucene.Net.WordNet.SynExpand")]
-[assembly: AssemblyCopyright("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyTrademark("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyDefaultAlias("Lucene.Net.SynExpand")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyInformationalVersionAttribute("2.0")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("2.0.0.1")]
-[assembly: AllowPartiallyTrustedCallers]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
-[assembly: ComVisibleAttribute(false)]
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynExpand/Contrib.WordNet.SynExpand.csproj
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynExpand/Contrib.WordNet.SynExpand.csproj b/src/contrib/WordNet/SynExpand/Contrib.WordNet.SynExpand.csproj
deleted file mode 100644
index 6bf1cb9..0000000
--- a/src/contrib/WordNet/SynExpand/Contrib.WordNet.SynExpand.csproj
+++ /dev/null
@@ -1,205 +0,0 @@
-\ufeff<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
- <PropertyGroup>
- <ProjectType>Local</ProjectType>
- <ProductVersion>8.0.30319</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{1407C9BA-337C-4C6C-B065-68328D3871B3}</ProjectGuid>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ApplicationIcon>App.ico</ApplicationIcon>
- <AssemblyKeyContainerName />
- <AssemblyName>Lucene.Net.WordNet.SynExpand</AssemblyName>
- <AssemblyOriginatorKeyFile />
- <DefaultClientScript>JScript</DefaultClientScript>
- <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
- <DefaultTargetSchema>IE50</DefaultTargetSchema>
- <DelaySign>false</DelaySign>
- <RootNamespace>SynExpand</RootNamespace>
- <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
- <StartupObject />
- <FileUpgradeFlags></FileUpgradeFlags>
- <OldToolsVersion>0.0</OldToolsVersion>
- <UpgradeBackupLocation />
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\$(Configuration.Replace("35", ""))\$(Framework)\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>DEBUG;TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>false</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>full</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug35|AnyCPU' ">
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\$(Configuration.Replace("35", ""))\$(Framework)\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>DEBUG;TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>false</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>full</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>true</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>pdbonly</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release35|AnyCPU' ">
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>true</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>pdbonly</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System">
- <Name>System</Name>
- </Reference>
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="SynExpand.cs">
- <SubType>Code</SubType>
- </Compile>
- <Content Include="App.ico" />
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include=".NETFramework,Version=v4.0">
- <Visible>False</Visible>
- <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\core\Lucene.Net.csproj">
- <Project>{5D4AD9BE-1FFB-41AB-9943-25737971BF57}</Project>
- <Name>Lucene.Net</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <PropertyGroup>
- <PreBuildEvent />
- <PostBuildEvent />
- </PropertyGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynExpand/SynExpand.cs
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynExpand/SynExpand.cs b/src/contrib/WordNet/SynExpand/SynExpand.cs
deleted file mode 100644
index 79498c0..0000000
--- a/src/contrib/WordNet/SynExpand/SynExpand.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Lucene.Net.Analysis;
-using Lucene.Net.Analysis.Standard;
-using Lucene.Net.Analysis.Tokenattributes;
-using Lucene.Net.Index;
-using Lucene.Net.Search;
-using Lucene.Net.Store;
-
-namespace WorldNet.Net
-{
-
-
- /// <summary> Expand a query by looking up synonyms for every term.
- /// You need to invoke <see cref="Syns2Index"/> first to build the synonym index.
- ///
- /// </summary>
- /// <seealso cref="Syns2Index" />
- public sealed class SynExpand
- {
- static List<String> already;
- private static BooleanQuery tmp;
-
- /// <summary> Test driver for synonym expansion.
- /// Uses boost factor of 0.9 for illustrative purposes.
- ///
- /// If you pass in the query "big dog" then it prints out:
- ///
- /// <pre>
- /// Query: big adult^0.9 bad^0.9 bighearted^0.9 boastful^0.9 boastfully^0.9 bounteous^0.9 bountiful^0.9 braggy^0.9 crowing^0.9 freehanded^0.9 giving^0.9 grown^0.9 grownup^0.9 handsome^0.9 large^0.9 liberal^0.9 magnanimous^0.9 momentous^0.9 openhanded^0.9 prominent^0.9 swelled^0.9 vainglorious^0.9 vauntingly^0.9
- /// dog andiron^0.9 blackguard^0.9 bounder^0.9 cad^0.9 chase^0.9 click^0.9 detent^0.9 dogtooth^0.9 firedog^0.9 frank^0.9 frankfurter^0.9 frump^0.9 heel^0.9 hotdog^0.9 hound^0.9 pawl^0.9 tag^0.9 tail^0.9 track^0.9 trail^0.9 weenie^0.9 wiener^0.9 wienerwurst^0.9
- /// </pre>
- /// </summary>
- [STAThread]
- public static void Main(String[] args)
- {
- if (args.Length != 2)
- {
- Console.Out.WriteLine(typeof(SynExpand) + " <index path> <query>");
- return;
- }
-
- var directory = FSDirectory.Open(new DirectoryInfo(args[0]));
- var searcher = new IndexSearcher(directory, true);
-
- String query = args[1];
- const string field = "contents";
-
- Query q = Expand(query, searcher, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT), field, 0.9f);
- System.Console.Out.WriteLine("Query: " + q.ToString(field));
-
- searcher.Close();
- directory.Close();
- }
-
-
- /// <summary>
- /// Perform synonym expansion on a query.
- /// </summary>
- /// <param name="query">users query that is assumed to not have any "special" query syntax, thus it should be just normal words, so "big dog" makes sense, but a query like "title:foo^1.2" doesn't as this should presumably be passed directly to the default query parser </param>
- /// <param name="syns">a opened to the Lucene index you previously created with <see cref="Syns2Index"/>. The searcher is not closed or otherwise altered. </param>
- /// <param name="a">optional analyzer used to parse the users query else <see cref="StandardAnalyzer"/> is used </param>
- /// <param name="field">optional field name to search in or null if you want the default of "contents" </param>
- /// <param name="boost">optional boost applied to synonyms else no boost is applied </param>
- /// <returns>the expanded Query </returns>
- public static Query Expand(String query,
- Searcher syns,
- Analyzer a,
- String field,
- float boost)
- {
- already = new List<String>(); // avoid dups
- var top = new List<String>(); // needs to be separately listed..
- if (field == null)
- field = "contents";
-
- if (a == null)
- a = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT);
-
- // [1] Parse query into separate words so that when we expand we can avoid dups
- var ts = a.TokenStream(field, new StringReader(query));
- var termAtt = ts.AddAttribute<TermAttribute>();
-
- while (ts.IncrementToken())
- {
- var word = termAtt.Term;
-
- if (!already.Contains(word))
- {
- already.Add(word);
- top.Add(word);
- }
- }
-
- tmp = new BooleanQuery();
-
- // [2] form query
- System.Collections.IEnumerator it = top.GetEnumerator();
- while (it.MoveNext())
- {
- // [2a] add to level words in
- var word = (String) it.Current;
- var tq = new TermQuery(new Term(field, word));
- tmp.Add(tq, Occur.SHOULD);
-
- var c = new CollectorImpl(field, boost);
- syns.Search(new TermQuery(new Term(Syns2Index.F_WORD, word)), c);
- }
-
- return tmp;
- }
-
-
- /// <summary>
- /// From project WordNet.Net.Syns2Index
- /// </summary>
- public class Syns2Index
- {
- /// <summary> </summary>
- public const String F_SYN = "syn";
-
- /// <summary> </summary>
- public const String F_WORD = "word";
- }
-
- /// <summary>
- /// CollectorImpl
- /// </summary>
- internal sealed class CollectorImpl : Collector
- {
- private IndexReader reader;
- private readonly string field;
- private readonly float boost;
-
- public CollectorImpl(string field, float boost)
- {
- this.field = field;
- this.boost = boost;
- }
-
- public override void SetScorer(Scorer scorer)
- {
- // Ignore
- }
-
- public override void Collect(int doc)
- {
- var d = reader.Document(doc);
- var values = d.GetValues(Syns2Index.F_SYN);
- foreach (var syn in values.Where(syn => !already.Contains(syn)))
- {
- already.Add(syn);
-
- var tq = new TermQuery(new Term(field, syn));
- if (boost > 0) // else keep normal 1.0
- tq.Boost = boost;
-
- tmp.Add(tq, Occur.SHOULD);
- }
- }
-
- public override void SetNextReader(IndexReader reader, int docBase)
- {
- this.reader = reader;
- }
-
- public override bool AcceptsDocsOutOfOrder
- {
- get { return true; }
- }
-
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynLookup/App.ico
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynLookup/App.ico b/src/contrib/WordNet/SynLookup/App.ico
deleted file mode 100644
index 3a5525f..0000000
Binary files a/src/contrib/WordNet/SynLookup/App.ico and /dev/null differ
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynLookup/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynLookup/AssemblyInfo.cs b/src/contrib/WordNet/SynLookup/AssemblyInfo.cs
deleted file mode 100644
index 1135b81..0000000
--- a/src/contrib/WordNet/SynLookup/AssemblyInfo.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Security;
-
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("Lucene.Net.WordNet.SynLookup")]
-[assembly: AssemblyDescription("The Apache Software Foundation Lucene.Net a full-text search engine library")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("The Apache Software Foundation")]
-[assembly: AssemblyProduct("Lucene.Net.WordNet.SynLookup")]
-[assembly: AssemblyCopyright("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyTrademark("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyDefaultAlias("Lucene.Net.SynLookup")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyInformationalVersionAttribute("2.0")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("2.0.0.1")]
-[assembly: AllowPartiallyTrustedCallers]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
-[assembly: ComVisibleAttribute(false)]
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynLookup/Contrib.WordNet.SynLookup.csproj
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynLookup/Contrib.WordNet.SynLookup.csproj b/src/contrib/WordNet/SynLookup/Contrib.WordNet.SynLookup.csproj
deleted file mode 100644
index a4693fe..0000000
--- a/src/contrib/WordNet/SynLookup/Contrib.WordNet.SynLookup.csproj
+++ /dev/null
@@ -1,205 +0,0 @@
-\ufeff<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
- <PropertyGroup>
- <ProjectType>Local</ProjectType>
- <ProductVersion>8.0.30319</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{2CA12E3F-76E1-4FA6-9E87-37079A7B7C69}</ProjectGuid>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ApplicationIcon>App.ico</ApplicationIcon>
- <AssemblyKeyContainerName />
- <AssemblyName>Lucene.Net.WordNet.SynLookup</AssemblyName>
- <AssemblyOriginatorKeyFile />
- <DefaultClientScript>JScript</DefaultClientScript>
- <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
- <DefaultTargetSchema>IE50</DefaultTargetSchema>
- <DelaySign>false</DelaySign>
- <RootNamespace>SynLookup</RootNamespace>
- <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
- <StartupObject />
- <FileUpgradeFlags></FileUpgradeFlags>
- <OldToolsVersion>0.0</OldToolsVersion>
- <UpgradeBackupLocation />
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\$(Configuration.Replace("35", ""))\$(Framework)\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>DEBUG;TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>false</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>full</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug35|AnyCPU' ">
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\$(Configuration.Replace("35", ""))\$(Framework)\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>DEBUG;TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>false</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>full</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>true</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>pdbonly</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release35|AnyCPU' ">
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <Framework>$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</Framework>
- <OutputPath>..\..\bin\contrib\WordNet\</OutputPath>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
- <ConfigurationOverrideFile />
- <DefineConstants>TRACE;$(Framework)</DefineConstants>
- <DocumentationFile></DocumentationFile>
- <DebugSymbols>true</DebugSymbols>
- <FileAlignment>4096</FileAlignment>
- <NoStdLib>false</NoStdLib>
- <NoWarn />
- <Optimize>true</Optimize>
- <RegisterForComInterop>false</RegisterForComInterop>
- <RemoveIntegerChecks>false</RemoveIntegerChecks>
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <WarningLevel>4</WarningLevel>
- <DebugType>pdbonly</DebugType>
- <ErrorReport>prompt</ErrorReport>
- <OutputType>Library</OutputType>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System">
- <Name>System</Name>
- </Reference>
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- <Reference Condition="'$(Framework)' == 'NET35'" Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="SynLookup.cs">
- <SubType>Code</SubType>
- </Compile>
- <Content Include="App.ico" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\core\Lucene.Net.csproj">
- <Project>{5D4AD9BE-1FFB-41AB-9943-25737971BF57}</Project>
- <Name>Lucene.Net</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include=".NETFramework,Version=v4.0">
- <Visible>False</Visible>
- <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <PropertyGroup>
- <PreBuildEvent />
- <PostBuildEvent />
- </PropertyGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/SynLookup/SynLookup.cs
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/SynLookup/SynLookup.cs b/src/contrib/WordNet/SynLookup/SynLookup.cs
deleted file mode 100644
index 024dcc9..0000000
--- a/src/contrib/WordNet/SynLookup/SynLookup.cs
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Lucene.Net.Analysis;
-using Lucene.Net.Analysis.Tokenattributes;
-using Lucene.Net.Index;
-using Lucene.Net.Search;
-using Lucene.Net.Store;
-
-namespace WorldNet.Net
-{
- /// <summary> Test program to look up synonyms.</summary>
- public class SynLookup
- {
- static List<String> already;
- private static BooleanQuery tmp;
-
- [STAThread]
- public static void Main(System.String[] args)
- {
- if (args.Length != 2)
- {
- System.Console.Out.WriteLine(typeof(SynLookup) + " <index path> <word>");
- return;
- }
-
- using (var directory = FSDirectory.Open(new DirectoryInfo(args[0])))
- {
- using (var searcher = new IndexSearcher(directory, true))
- {
-
- String word = args[1];
- Query query = new TermQuery(new Term(Syns2Index.F_WORD, word));
- var countingCollector = new CountingCollector();
- searcher.Search(query, countingCollector);
-
- if (countingCollector.numHits == 0)
- {
- Console.Out.WriteLine("No synonyms found for " + word);
- }
- else
- {
- Console.Out.WriteLine("Synonyms found for \"" + word + "\":");
- }
-
- var hits = searcher.Search(query, countingCollector.numHits).ScoreDocs;
-
- foreach (var v in
- hits.Select(t => searcher.Doc(t.Doc)).Select(doc => doc.GetValues(Syns2Index.F_SYN)).SelectMany(values => values))
- {
- Console.Out.WriteLine(v);
- }
-
- }
- }
- }
-
- /// <summary>
- /// Perform synonym expansion on a query.
- /// </summary>
- /// <param name="query">query</param>
- /// <param name="syns">syns</param>
- /// <param name="a">a</param>
- /// <param name="field">field</param>
- /// <param name="boost">boost</param>
- public static Query Expand(String query,
- Searcher syns,
- Analyzer a,
- String field,
- float boost)
- {
- already = new List<String>(); // avoid dups
- var top = new List<String>(); // needs to be separately listed..
-
- var ts = a.TokenStream(field, new StringReader(query));
- var termAtt = ts.AddAttribute<TermAttribute>();
-
- while (ts.IncrementToken())
- {
- var word = termAtt.Term;
-
- if (!already.Contains(word))
- {
- already.Add(word);
- top.Add(word);
- }
- }
-
- tmp = new BooleanQuery();
-
- // [2] form query
- System.Collections.IEnumerator it = top.GetEnumerator();
- while (it.MoveNext())
- {
- // [2a] add to level words in
- var word = (String)it.Current;
- var tq = new TermQuery(new Term(field, word));
- tmp.Add(tq, Occur.SHOULD);
-
- var c = new CollectorImpl(field, boost);
- syns.Search(new TermQuery(new Term(Syns2Index.F_WORD, word)), c);
- }
-
- return tmp;
- }
-
- internal sealed class CountingCollector : Collector
- {
- public int numHits;
-
- public override void SetScorer(Scorer scorer)
- { }
-
- public override void Collect(int doc)
- {
- numHits++;
- }
-
- public override void SetNextReader(IndexReader reader, int docBase)
- { }
-
- public override bool AcceptsDocsOutOfOrder
- {
- get { return true; }
- }
- }
-
- /// <summary>
- /// CollectorImpl
- /// </summary>
- internal sealed class CollectorImpl : Collector
- {
- private IndexReader reader;
- private readonly string field;
- private readonly float boost;
-
- public CollectorImpl(string field, float boost)
- {
- this.field = field;
- this.boost = boost;
- }
-
- public override void SetScorer(Scorer scorer)
- {
- // Ignore
- }
-
- public override void Collect(int doc)
- {
- var d = reader.Document(doc);
- var values = d.GetValues(Syns2Index.F_SYN);
- foreach (var syn in values.Where(syn => !already.Contains(syn)))
- {
- already.Add(syn);
-
- var tq = new TermQuery(new Term(field, syn));
- if (boost > 0) // else keep normal 1.0
- tq.Boost = boost;
-
- tmp.Add(tq, Occur.SHOULD);
- }
- }
-
- public override void SetNextReader(IndexReader reader, int docBase)
- {
- this.reader = reader;
- }
-
- public override bool AcceptsDocsOutOfOrder
- {
- get { return true; }
- }
-
- }
-
- /// <summary>
- /// From project WordNet.Net.Syns2Index
- /// </summary>
- public class Syns2Index
- {
- /// <summary> </summary>
- public const String F_SYN = "syn";
-
- /// <summary> </summary>
- public const String F_WORD = "word";
- }
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/Syns2Index/App.ico
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/Syns2Index/App.ico b/src/contrib/WordNet/Syns2Index/App.ico
deleted file mode 100644
index 3a5525f..0000000
Binary files a/src/contrib/WordNet/Syns2Index/App.ico and /dev/null differ
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02362804/src/contrib/WordNet/Syns2Index/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/WordNet/Syns2Index/AssemblyInfo.cs b/src/contrib/WordNet/Syns2Index/AssemblyInfo.cs
deleted file mode 100644
index 827e272..0000000
--- a/src/contrib/WordNet/Syns2Index/AssemblyInfo.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Security;
-
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("Lucene.Net.Contrib.WordNet.Syns2Index")]
-[assembly: AssemblyDescription("The Apache Software Foundation Lucene.Net a full-text search engine library")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("The Apache Software Foundation")]
-[assembly: AssemblyProduct("Lucene.Net.Contrib.WordNet.Syns2Index")]
-[assembly: AssemblyCopyright("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyTrademark("Copyright 2007 - 2011 The Apache Software Foundation")]
-[assembly: AssemblyDefaultAlias("Lucene.Net.Syns2Index")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyInformationalVersionAttribute("2.0")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("2.0.0.1")]
-[assembly: AllowPartiallyTrustedCallers]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
-[assembly: ComVisibleAttribute(false)]