Come abilitare lo stemming durante la ricerca utilizzando lucene.net?Come abilitare lo stemming durante la ricerca usando lucene.net?
risposta
Per fare ciò è necessario scrivere la propria classe di analizzatore. Questo è relativamente semplice. Ecco quello che sto usando. Combina il filtraggio delle parole d'arresto. Porter e (potrebbe essere troppo per le tue esigenze) spogliarsi degli accenti dei personaggi.
/// <summary>
/// An analyzer that implements a number of filters. Including porter stemming,
/// Diacritic stripping, and stop word filtering.
/// </summary>
public class CustomAnalyzer : Analyzer
{
/// <summary>
/// A rather short list of stop words that is fine for basic search use.
/// </summary>
private static readonly string[] stopWords = new[]
{
"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "000", "$", "£",
"about", "after", "all", "also", "an", "and",
"another", "any", "are", "as", "at", "be",
"because", "been", "before", "being", "between",
"both", "but", "by", "came", "can", "come",
"could", "did", "do", "does", "each", "else",
"for", "from", "get", "got", "has", "had",
"he", "have", "her", "here", "him", "himself",
"his", "how","if", "in", "into", "is", "it",
"its", "just", "like", "make", "many", "me",
"might", "more", "most", "much", "must", "my",
"never", "now", "of", "on", "only", "or",
"other", "our", "out", "over", "re", "said",
"same", "see", "should", "since", "so", "some",
"still", "such", "take", "than", "that", "the",
"their", "them", "then", "there", "these",
"they", "this", "those", "through", "to", "too",
"under", "up", "use", "very", "want", "was",
"way", "we", "well", "were", "what", "when",
"where", "which", "while", "who", "will",
"with", "would", "you", "your",
"a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z"
};
private Hashtable stopTable;
/// <summary>
/// Creates an analyzer with the default stop word list.
/// </summary>
public CustomAnalyzer() : this(stopWords) {}
/// <summary>
/// Creates an analyzer with the passed in stop words list.
/// </summary>
public CustomAnalyzer(string[] stopWords)
{
stopTable = StopFilter.MakeStopSet(stopWords);
}
public override TokenStream TokenStream(string fieldName, System.IO.TextReader reader)
{
return new PorterStemFilter(new ISOLatin1AccentFilter(new StopFilter(new LowerCaseTokenizer(reader), stopWords)));
}
}
Grazie, ci proverò. – devson
+1 grazie Jack, proprio quello che stavo cercando. Se potessi, segnerei questo come risposta! – andy
Ho usato il tuo esempio, tuttavia non sto ottenendo risultati per le query per un numero '4656' (l'analizzatore standard funziona) Ho sostituito le parole di arresto con il built in' StopAnalyzer.ENGLISH_STOP_WORDS' che non include numeri, nessuna idea cosa sta succedendo Lì? – Myster
È possibile utilizzare Snowball o PorterStemFilter. Vedere Java Analyzer documentation come guida per combinare diversi filtri/Tokenizzatori/Analizzatori. Si noti che è necessario utilizzare lo stesso analizzatore per l'indicizzazione e il recupero, in modo che la gestione dello stemming dovrebbe iniziare al momento dell'indicizzazione.
Grazie, ci proverò. – devson
- 1. Lucene.net ricerca di prossimità
- 2. ElasticSearch Stemming
- 3. Evitare la rimozione dell'indice Lucene.NET corrente durante la ricostruzione
- 4. Come utilizzare Lucene.NET per implementare la ricerca in un sito come Stack Overflow?
- 5. Come integrare NHibernate con Lucene.Net
- 6. Come abilitare "ricerca live" in eclissi?
- 7. come abilitare lo zoom nel controllo grafico di Microsoft usando la rotella del mouse
- 8. Lucene.NET l'evidenziazione della ricerca che rispetta i tag HTML
- 9. Concorrenza in Lucene.NET.
- 10. lucene.net combina più filtri e nessun termine di ricerca
- 11. Lucene.Net: Come posso aggiungere un filtro per la data ai miei risultati di ricerca?
- 12. Come disabilitare e abilitare la tabella HTML usando javascript?
- 13. Come ottenere il massimo da Lucene.net
- 14. SQL Server 2008 Ricerca testo completo (FTS) rispetto a Lucene.NET
- 15. Stemming with R Text Analysis
- 16. Come abilitare/disabilitare lo scorrimento in UITableView?
- 17. Come posso abilitare lo zoom su Android?
- 18. Tag JSP + scriptlet. Come abilitare lo scriptlet?
- 19. Come abilitare lo script java in webView
- 20. Memorizzazione dati relazionali in un indice Lucene.NET
- 21. In una ricerca Lucene/Lucene.net, come faccio a contare il numero di visite per documento?
- 22. Abilitare la scheda SD durante il debug USB?
- 23. qual è la vera differenza tra lemmatization vs stemming
- 24. esatta cerca categoria utilizzando Lucene.net
- 25. Ricerca incrementale Vim durante la sostituzione
- 26. Configurare Lucene.Net con SQL Server
- 27. crea indici per la ricerca usando MongoTemplate?
- 28. Come abilitare lo scheduler di Fair in Spark?
- 29. Blocco durante la ricerca in due sezioni
- 30. Mostra testo nascosto durante la ricerca
Quale analizzatore stai utilizzando? – Kane
Sto usando l'analizzatore standard. – devson