Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're not implementing this for academic reasons you should consider using the <a href="http://lucene.apache.org/java/docs/index.html" rel="noreferrer">Lucene</a> library. In either case it might be good for reference. It has classes for tokenization, stop word filtering, stemming and similarity. Here's a quick example using Lucene 3.0 to remove stop words and stem an input string:</p> <pre><code>public static String removeStopWordsAndStem(String input) throws IOException { Set&lt;String&gt; stopWords = new HashSet&lt;String&gt;(); stopWords.add("a"); stopWords.add("I"); stopWords.add("the"); TokenStream tokenStream = new StandardTokenizer( Version.LUCENE_30, new StringReader(input)); tokenStream = new StopFilter(true, tokenStream, stopWords); tokenStream = new PorterStemFilter(tokenStream); StringBuilder sb = new StringBuilder(); TermAttribute termAttr = tokenStream.getAttribute(TermAttribute.class); while (tokenStream.incrementToken()) { if (sb.length() &gt; 0) { sb.append(" "); } sb.append(termAttr.term()); } return sb.toString(); } </code></pre> <p>Which if used on your strings like this:</p> <pre><code>public static void main(String[] args) throws IOException { String one = "I decided buy something from the shop."; String two = "Nevertheless I decidedly bought something from a shop."; System.out.println(removeStopWordsAndStem(one)); System.out.println(removeStopWordsAndStem(two)); } </code></pre> <p>Yields this output:</p> <pre><code>decid bui someth from shop Nevertheless decidedli bought someth from shop </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload