Sto provando a convertire le stringhe in ngram. Stranamente nella documentazione per il NGramTokenizer non vedo un metodo che restituirà i singoli ngram che sono stati tokenizzati. In effetti vedo solo due metodi nella classe NGramTokenizer che restituiscono oggetti stringa.Java Lucene NGramTokenizer
Ecco il codice che ho:
Reader reader = new StringReader("This is a test string");
NGramTokenizer gramTokenizer = new NGramTokenizer(reader, 1, 3);
- Dove sono i ngrams che sono stati token?
- Come posso ottenere l'output in Stringhe/Parole?
Voglio che il mio output sia come: Questo è, a, test, stringa, Questo è, è un test, una stringa di prova, Questo è un, è un test, una stringa di test.
Cosa posso fare con le stringhe, invece di caratteri in termini di attributi? Quindi il mio risultato sarebbe qualcosa del tipo: Questo è, a, test, stringa, Questo è, è un test, ... una stringa di test. – CodeKingPlusPlus
Ok, non è questo che NGramTokenizer di Lucene è progettato per gestire. Quello che vorresti usare, credo, è uno ShingleFilter combinato con StandardTokenizer. Aggiornerò la mia risposta, più facile da esprimere lì ... – femtoRgon
Conoscete eventuali filtri di parole d'arresto che posso utilizzare nel processo di tokenizzazione? – CodeKingPlusPlus