Skip to content

[Issue #29] (Team 2) Dynamic Programming Algorithm for Query Rewriter - #120

Merged
ss3n merged 7 commits into
masterfrom
yoda-dp
May 24, 2016
Merged

ss3n merged 7 commits into
masterfrom
yoda-dp

Conversation

@ss3n

@ss3n ss3n commented May 24, 2016

Copy link
Copy Markdown
Contributor
  • Added English dictionary file, with frequencies.
  • Modified FuzzyParser to implement the dynamic programming algorithm, implemented by @JavierJia which is referenced in the comment thread, under (Team 2) Design: Query Rewriter #29
  • Modified the QueryRewriterTest to reflect the new expected results from the QueryRewriter

@chenlica : Can you give this a review?

@ss3n ss3n changed the title (Team 2) Dynamic Programming Algorithm for Query Rewriter [Issue #29] (Team 2) Dynamic Programming Algorithm for Query Rewriter May 24, 2016
*/
public class FuzzyTokenizer
{
public class FuzzyTokenizer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name FuzzyTokenizer is not very accurate. Can we rename it to QueryRewriter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that it's a helper class for QueryRewriter. Still I prefer a different name. Any suggestions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood... Refactoring to QuerySegmenter
Just asking, after the refactoring, is it ok to have the method named getFuzzyTokens ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to avoid overloading the word "fuzzy". So I prefer to use getTokens().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.

@ss3n

ss3n commented May 24, 2016 •

Copy link
Copy Markdown
Contributor Author

Actually QueryRewriter is the main class... It in turn calls the FuzzyTokenizer class to detect missing white spaces. The reason we have separated the two classes is because later, QueryRewriter would also perform "synonym" matching as well.

/**
* When called returns a single-member list containing most-likely tokenization of phrase
* Splits phrase into terms by whitespace delimiter
* For each term, rewrites(tokenizes) term to detect likely missing spaces

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an example to the comments.

@ss3n

ss3n commented May 24, 2016

Copy link
Copy Markdown
Contributor Author

@chenlica : Added an example in the comments as suggested... Kindly take a look

@chenlica

Copy link
Copy Markdown
Contributor

In the QueryRewriter class, is it better to make fuzzyTokenizer.getFuzzyTokens() a static function if it only needs a query string?

this.phrase = phrase;
}

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For line 42 public FuzzyTokenizer(String phrase, rename phrase to queryString since phrase has a special meaning in other modules.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does make sense for fuzzyTokenizer.getFuzzyTokens() to be a static function. We are making changes as suggested.

@chenlica

Copy link
Copy Markdown
Contributor

High-level comments:

  • Make FuzzyTokenizer.getFuzzyTokens() a static function.
  • Possibly rename FuzzyTokenizer to QuerySegmenter. If you don't agree, that's fine.
  • Wait for @JavierJia to review the DP algorithm.

}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tokenization to tokenizedQuery.

@ss3n

ss3n commented May 24, 2016

Copy link
Copy Markdown
Contributor Author
  • Refactored FuzzyTokenizer to QuerySegmenter
  • Refactored phrase to queryString
  • Refactored getFuzzyTokens to getTokens
  • Converted getTokens to static function and made corresponding changes to QueryRewriter

@chenlica : Kindly take a look.

@chenlica

Copy link
Copy Markdown
Contributor

To unblock you, no need to wait for the review from @JavierJia . Go ahead to do the merge after making those changes. We will let @JavierJia doublecheck the logic even after the merge.

@chenlica

Copy link
Copy Markdown
Contributor

Looks good. Please go ahead to do the merge!

@ss3n

ss3n commented May 24, 2016

Copy link
Copy Markdown
Contributor Author

Missed refactoring a variable name...

@chenlica

Copy link
Copy Markdown
Contributor

Looks good. Please go ahead to do the merge.

@ss3n

ss3n commented May 24, 2016

Copy link
Copy Markdown
Contributor Author
  • Overloaded QueryRewriter constructor to accept flag for returning all possible tokenizations
  • Included corresponding test cases in QueryRewriterTest
  • Cleaned some noisy entries in word-frequency map

@chenlica : Can you take a look at the changes?

List<String> queryStrings;
if(allSegmentations)
queryStrings = QuerySegmenter.bruteGetTokens(searchQuery);
else

@chenlica chenlica May 24, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bruteGetTokens -> getTokensBruteForce

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were thinking of refactoring bruteGetTokens -> getAllTokens and getTokens -> getLikelyTokens.
getAllTokens can internally call rewriteTermBruteForce and getLikelyTokens can call rewriteTermDP
@chenlica : Do you think that would be ok?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. The name rewriteTermDP can be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants