Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:43:15+00:00 2026-06-16T00:43:15+00:00

I’m currently giving the user an option to include stop words or not when

  • 0

I’m currently giving the user an option to include stop words or not when filtering a body of text for ngram frequencies. Typically, this is done as follows:

snowballAnalyzer = new SnowballAnalyzer(Version.LUCENE_30, "English", stopWords);               
shingleAnalyzer = new ShingleAnalyzerWrapper(snowballAnalyzer, this.getnGramLength());

stopWords is set to either a full list of words to include in ngrams or to remove from them. this.getnGramLength()); simply contains the current ngram length up to a maximum of three.

If I use stopwords in filtering text “satellite is definitely falling to Earth” for trigrams, the output is:

No=1, Key=to, Freq=1
No=2, Key=definitely, Freq=1
No=3, Key=falling to earth, Freq=1
No=4, Key=satellite, Freq=1
No=5, Key=is, Freq=1
No=6, Key=definitely falling to, Freq=1
No=7, Key=definitely falling, Freq=1
No=8, Key=falling, Freq=1
No=9, Key=to earth, Freq=1
No=10, Key=satellite is, Freq=1
No=11, Key=is definitely, Freq=1
No=12, Key=falling to, Freq=1
No=13, Key=is definitely falling, Freq=1
No=14, Key=earth, Freq=1
No=15, Key=satellite is definitely, Freq=1

But if I don’t use stopwords for trigrams, the output is this:

No=1, Key=satellite, Freq=1
No=2, Key=falling _, Freq=1
No=3, Key=satellite _ _, Freq=1
No=4, Key=_ earth, Freq=1
No=5, Key=falling, Freq=1
No=6, Key=satellite _, Freq=1
No=7, Key=_ _, Freq=1
No=8, Key=_ falling _, Freq=1
No=9, Key=falling _ earth, Freq=1
No=10, Key=_, Freq=3
No=11, Key=earth, Freq=1
No=12, Key=_ _ falling, Freq=1
No=13, Key=_ falling, Freq=1

Why am I seeing underscores? I would have thought to see simple unigrams, “satellite falling”, “falling earth” and “satellite falling earth”? Definitely is in the stopwords set I’m using.

I can just filter out the results with underscores but…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:43:16+00:00Added an answer on June 16, 2026 at 12:43 am

    The underscores represent a ‘missing stop word/s’. To avoid that behavior you should set the enablePositionIncrements to false but SnowballAnalyzer (now deprecated in 4.0.0-Beta) doesn’t let you do it.

    One solution is using a StandardAnalyzer with no stop words first, and then decorate the output with a StopFilter, SnowballFilter, and ShingleFilter. Example for bi-grams in Lucene 4.0.0-Beta:

    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40, CharArraySet.EMPTY_SET);
    TokenStream tokenStream = analyzer.tokenStream("content", new StringReader(input));
    StopFilter stopFilter = new StopFilter(Version.LUCENE_40, tokenStream, stopWords);
    stopFilter.setEnablePositionIncrements(false);
    SnowballFilter snowballFilter = new SnowballFilter(stopFilter, "English");
    ShingleFilter bigramShingleFilter = new ShingleFilter(snowballFilter, 2, 2);
    

    Hope that this puts you on the right track!

    EDIT

    Not possible anymore with Lucene v4.4+, still looking for a nice alternative…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a FlashCard App. Part of this is giving the user the option
I'm currently writing about dynamic typing, and I'm giving an example of Excel interop.
Currently I am using HTML files for parts of my user interface. I display
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
I'm an app where everything is tied to the currently connected user. So far
The whole concept of exception handling is giving me headaches. Currently, what I want
For a project I'm currently working on the user needs to be able to
I am currently doing a uni assignment as a fresher so I'm not very
I'm pretty new to ORMs, and I'm currently giving Telerik OpenAccess ORM a try
Initially, my map would be pointing to the user's current location. I am giving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.