You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "MartinDemberger (via GitHub)" <gi...@apache.org> on 2023/07/13 07:08:32 UTC
[GitHub] [lucene] MartinDemberger opened a new pull request, #12437: Added the abbility to get noSubMatches and noOverlapping Matches
MartinDemberger opened a new pull request, #12437:
URL: https://github.com/apache/lucene/pull/12437
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Lucene or Solr:
* https://issues.apache.org/jira/projects/LUCENE
* https://issues.apache.org/jira/projects/SOLR
You will need to create an account in Jira in order to create an issue.
The title of the PR should reference the Jira issue number in the form:
* LUCENE-####: <short description of problem or changes>
* SOLR-####: <short description of problem or changes>
LUCENE and SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
This is the solution for LUCENE-8183. The change is taken form the patch in the workitem.
# Solution
## New Parameters:
noSubMatches: true/false
noOverlappingMatches: true/false
together with the existing onlyLongestMatch those can be used to define what subwords should be added as tokens. Functionality is as described above.
Typically users will only want to include one of the three attributes as enabling noOverlappingMatches is the most restrictive and noSubMatches is more restrictive as onlyLongestMatch. When enabling a more restrictive option the state of the less restrictive does not have any effect.
Because of that it would be an option to refactor this to an single attribute with different setting, but this would require to think about backward compatibility for configurations that do use onlyLongestMatch=true at the moment.
## Algorithm
If processing of subWords is deactivated (any of onlyLongestMatch, noSubMatches, noOverlappingMatches is active) the algorithm first checks if the token is part of the dictionary. If so it returns immediately. This is to avoid adding tokens for subwords if the token itself is in the dictionary (see #testNoSubAndTokenInDictionary for more info).
I changed the iteration direction of the inner for loop to start with the longest possible subword as this simplified the code.
NOTE: that this also changes the order of the Tokens in the token stream but as all tokens are at the same position that should not make any difference. I had however to modify some existing tests as those where sensitive to the ordering
# Tests
I added two test methods in TestCompoundWordTokenFilter
1. #testNoSubAndNoOverlap() tests the expected behaviour of the noSubMatches and noOverlappingMatches options
2. #testNoSubAndTokenInDictionary() tests that no tokens for subwords are added in the case that the token in part of the dictionary
In addition TestHyphenationCompoundWordTokenFilterFactory#testLucene8183() asserts that the new configuration options are parsed.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [x] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [x] I have developed this patch against the `master` branch.
- [x] I have run `./gradlew check`.
- [x] I have added tests for my changes.
- [ ] I have added documentation for the [Ref Guide](https://github.com/apache/lucene-solr/tree/master/solr/solr-ref-guide) (for Solr changes only).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] MartinDemberger commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "MartinDemberger (via GitHub)" <gi...@apache.org>.
MartinDemberger commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267919504
##########
lucene/CHANGES.txt:
##########
@@ -65,6 +65,8 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* Lucene-8183: Added the abbility to get noSubMatches and noOverlappingMatches in HyphenationCompoundWordFilter (Martin Demberger, original from Rupert Westenthaler)
Review Comment:
I understand. I hope it's in the correct section now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] MartinDemberger commented on pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "MartinDemberger (via GitHub)" <gi...@apache.org>.
MartinDemberger commented on PR #12437:
URL: https://github.com/apache/lucene/pull/12437#issuecomment-1640968390
This is my first PR for lucene. Thank you for your patience and help. If I can improve something please let me know.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #12437:
URL: https://github.com/apache/lucene/pull/12437#issuecomment-1634134373
There are some complains by the ecj linter, please check your code (unused variables and/or formatting).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] MartinDemberger commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "MartinDemberger (via GitHub)" <gi...@apache.org>.
MartinDemberger commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267286254
##########
lucene/CHANGES.txt:
##########
@@ -65,6 +65,8 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* Lucene-8183: Added the abbility to get noSubMatches and noOverlappingMatches in HyphenationCompoundWordFilter (Martin Demberger, original from Rupert Westenthaler)
Review Comment:
I have moved it. Is this the correct position?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1262454229
##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilter.java:
##########
@@ -34,6 +34,9 @@
*/
public class HyphenationCompoundWordTokenFilter extends CompoundWordTokenFilterBase {
private final HyphenationTree hyphenator;
+ private boolean noSubMatches;
Review Comment:
this should be final, too
##########
lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java:
##########
@@ -47,6 +47,33 @@ public void testHyphenationWithDictionary() throws Exception {
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 0, 0});
}
+ /**
+ * just tests that the two no configuration options are correctly processed tests for the
+ * functionality are part of {@link TestCompoundWordTokenFilter}
+ */
+ public void testLucene8183() throws Exception {
+ Reader reader = new StringReader("basketballkurv");
+ TokenStream stream = new MockTokenizer(MockTokenizer.WHITESPACE, false);
+ ((Tokenizer) stream).setReader(reader);
+ stream =
+ tokenFilterFactory(
+ "HyphenationCompoundWord",
+ "hyphenator",
+ "da_UTF8.xml",
Review Comment:
is this fine to use the danish dictionary here, because it "just works"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] MartinDemberger commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "MartinDemberger (via GitHub)" <gi...@apache.org>.
MartinDemberger commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267179992
##########
lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java:
##########
@@ -47,6 +47,33 @@ public void testHyphenationWithDictionary() throws Exception {
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 0, 0});
}
+ /**
+ * just tests that the two no configuration options are correctly processed tests for the
+ * functionality are part of {@link TestCompoundWordTokenFilter}
+ */
+ public void testLucene8183() throws Exception {
+ Reader reader = new StringReader("basketballkurv");
+ TokenStream stream = new MockTokenizer(MockTokenizer.WHITESPACE, false);
+ ((Tokenizer) stream).setReader(reader);
+ stream =
+ tokenFilterFactory(
+ "HyphenationCompoundWord",
+ "hyphenator",
+ "da_UTF8.xml",
Review Comment:
This dictionary is mentioned in the original issue. Should I change to a german dictionary?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267903574
##########
lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java:
##########
@@ -47,6 +47,33 @@ public void testHyphenationWithDictionary() throws Exception {
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 0, 0});
}
+ /**
+ * just tests that the two no configuration options are correctly processed tests for the
+ * functionality are part of {@link TestCompoundWordTokenFilter}
+ */
+ public void testLucene8183() throws Exception {
+ Reader reader = new StringReader("basketballkurv");
+ TokenStream stream = new MockTokenizer(MockTokenizer.WHITESPACE, false);
+ ((Tokenizer) stream).setReader(reader);
+ stream =
+ tokenFilterFactory(
+ "HyphenationCompoundWord",
+ "hyphenator",
+ "da_UTF8.xml",
Review Comment:
I see the comment: https://github.com/apache/lucene/issues/9231#issuecomment-1223859623
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1262467919
##########
lucene/CHANGES.txt:
##########
@@ -65,6 +65,8 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* Lucene-8183: Added the abbility to get noSubMatches and noOverlappingMatches in HyphenationCompoundWordFilter (Martin Demberger, original from Rupert Westenthaler)
Review Comment:
If we will release this with 9.8 (which should be fine), we need to move the entry down.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267297167
##########
lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java:
##########
@@ -47,6 +47,33 @@ public void testHyphenationWithDictionary() throws Exception {
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 0, 0});
}
+ /**
+ * just tests that the two no configuration options are correctly processed tests for the
+ * functionality are part of {@link TestCompoundWordTokenFilter}
+ */
+ public void testLucene8183() throws Exception {
+ Reader reader = new StringReader("basketballkurv");
+ TokenStream stream = new MockTokenizer(MockTokenizer.WHITESPACE, false);
+ ((Tokenizer) stream).setReader(reader);
+ stream =
+ tokenFilterFactory(
+ "HyphenationCompoundWord",
+ "hyphenator",
+ "da_UTF8.xml",
Review Comment:
The problem with the dictionary is the license. So we should not add the originals. If this hacky small Sixt works for the test all is fine.
##########
lucene/CHANGES.txt:
##########
@@ -65,6 +65,8 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* Lucene-8183: Added the abbility to get noSubMatches and noOverlappingMatches in HyphenationCompoundWordFilter (Martin Demberger, original from Rupert Westenthaler)
Review Comment:
You just moved it to enhancement. Please move it down after the 9.8 version because I will merge this later to this branch
So fix Version will be Luce e 9.8 not 10.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267297167
##########
lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java:
##########
@@ -47,6 +47,33 @@ public void testHyphenationWithDictionary() throws Exception {
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 0, 0});
}
+ /**
+ * just tests that the two no configuration options are correctly processed tests for the
+ * functionality are part of {@link TestCompoundWordTokenFilter}
+ */
+ public void testLucene8183() throws Exception {
+ Reader reader = new StringReader("basketballkurv");
+ TokenStream stream = new MockTokenizer(MockTokenizer.WHITESPACE, false);
+ ((Tokenizer) stream).setReader(reader);
+ stream =
+ tokenFilterFactory(
+ "HyphenationCompoundWord",
+ "hyphenator",
+ "da_UTF8.xml",
Review Comment:
The problem with the German dictionary is the license. So we should not add the originals from FOP. If the Danish one works for the test all is fine (I think it is already only a subset of Danish).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler merged pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler merged PR #12437:
URL: https://github.com/apache/lucene/pull/12437
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on a diff in pull request #12437: LUCENE-8183: Added the abbility to get noSubMatches and noOverlapping Matches
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #12437:
URL: https://github.com/apache/lucene/pull/12437#discussion_r1267299166
##########
lucene/CHANGES.txt:
##########
@@ -65,6 +65,8 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* Lucene-8183: Added the abbility to get noSubMatches and noOverlappingMatches in HyphenationCompoundWordFilter (Martin Demberger, original from Rupert Westenthaler)
Review Comment:
You just moved it to enhancement. Please move it down after the 9.8 version because I will merge this later to this branch
So fix Version will be Lucene 9.8 not 10.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org