You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/01/20 12:58:05 UTC

[GitHub] [lucene-solr] donnerpeter opened a new pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

donnerpeter opened a new pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224


   <!--
   _(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
   
   Hunspell supports numbers like `42` or `111.222`, but only for spellchecking, without any stemming. Lucene should, too.
   
   # Solution
   
   Copy the corresponding logic from Hunspell C++.
   
   # Tests
   
   The test is taken from Hunspell C++ as well.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] 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.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] 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)
   - [ ] I have developed this patch against the `master` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] 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.

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-solr] dweiss merged pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
dweiss merged pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224


   


----------------------------------------------------------------
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.

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-solr] dweiss commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561677984



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       Should this follow Hunspell's rules exactly? I ask because you could make it more general by scanning unicode codepoints and then verifying each codepoint's attributes (whether it is a numeric or not). I know this is a tiny fraction of use cases but unicode has all sorts of odd characters that are numerics:
   
   https://www.fileformat.info/info/unicode/category/Nd/list.htm

##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/i53643.good
##########
@@ -0,0 +1,21 @@
+1
+12
+123
+1234
+12345
+123456
+1234567
+1.1
+1.12
+1.123
+1.1234
+1.12345
+1.123456
+12.1
+123.12
+1234.123
+12345.1234
+123456.12345
+1234567.123456
+4,2

Review comment:
       Yeah.... this is really locale-specific. Can't be solved accurately without the context (locale). Even if you do have the locale, people write inconsistently (grouping and fraction separators).




----------------------------------------------------------------
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.

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-solr] donnerpeter commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
donnerpeter commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561804052



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       My goal is to have a drop-in replacement for Hunspell (at least for some languages), so I wouldn't generalize its behavior for now. Maybe later, and preferably accompanied by corresponding changes in native Hunspell.

##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/i53643.good
##########
@@ -0,0 +1,21 @@
+1
+12
+123
+1234
+12345
+123456
+1234567
+1.1
+1.12
+1.123
+1.1234
+1.12345
+1.123456
+12.1
+123.12
+1234.123
+12345.1234
+123456.12345
+1234567.123456
+4,2

Review comment:
       Very specific, yes. That's how Hunspell behaves: https://github.com/hunspell/hunspell/blob/master/src/hunspell/hunspell.cxx#L501




----------------------------------------------------------------
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.

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-solr] donnerpeter commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
donnerpeter commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561804052



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       My goal is to have a drop-in replacement for Hunspell (at least for some languages), so I wouldn't generalize its behavior for now. Maybe later, and preferably accompanied by corresponding changes in native Hunspell.




----------------------------------------------------------------
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.

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-solr] dweiss commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561677984



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       Should this follow Hunspell's rules exactly? I ask because you could make it more general by scanning unicode codepoints and then verifying each codepoint's attributes (whether it is a numeric or not). I know this is a tiny fraction of use cases but unicode has all sorts of odd characters that are numerics:
   
   https://www.fileformat.info/info/unicode/category/Nd/list.htm

##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/i53643.good
##########
@@ -0,0 +1,21 @@
+1
+12
+123
+1234
+12345
+123456
+1234567
+1.1
+1.12
+1.123
+1.1234
+1.12345
+1.123456
+12.1
+123.12
+1234.123
+12345.1234
+123456.12345
+1234567.123456
+4,2

Review comment:
       Yeah.... this is really locale-specific. Can't be solved accurately without the context (locale). Even if you do have the locale, people write inconsistently (grouping and fraction separators).

##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       Yup, I thought so.




----------------------------------------------------------------
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.

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-solr] dweiss commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561804714



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -51,6 +57,28 @@ public boolean spell(String word) {
     return false;
   }
 
+  private static boolean isNumber(String s) {
+    int i = 0;
+    while (i < s.length()) {

Review comment:
       Yup, I thought so.




----------------------------------------------------------------
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.

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-solr] donnerpeter commented on a change in pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
donnerpeter commented on a change in pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224#discussion_r561804979



##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/i53643.good
##########
@@ -0,0 +1,21 @@
+1
+12
+123
+1234
+12345
+123456
+1234567
+1.1
+1.12
+1.123
+1.1234
+1.12345
+1.123456
+12.1
+123.12
+1234.123
+12345.1234
+123456.12345
+1234567.123456
+4,2

Review comment:
       Very specific, yes. That's how Hunspell behaves: https://github.com/hunspell/hunspell/blob/master/src/hunspell/hunspell.cxx#L501




----------------------------------------------------------------
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.

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-solr] dweiss merged pull request #2224: LUCENE-9681: Hunspell spellchecker: support numbers with separators

Posted by GitBox <gi...@apache.org>.
dweiss merged pull request #2224:
URL: https://github.com/apache/lucene-solr/pull/2224


   


----------------------------------------------------------------
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.

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