You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by "mawiesne (via GitHub)" <gi...@apache.org> on 2023/03/04 12:41:05 UTC

[GitHub] [opennlp] mawiesne opened a new pull request, #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

mawiesne opened a new pull request, #516:
URL: https://github.com/apache/opennlp/pull/516

   Change
   -
   - adds Spanish and Italian alphabet regex patterns to `...lang.Factory`
   - adjusts German pattern to include `é` and `É` to cover established loan words such as "Café" or "Cuvée"
   - adjusts `TokenizerFactoryTest` to use langCode "eng" instead of "spa" as Spanish will (now) return a specialized pattern
   
   Tasks
   -
   Thank you for contributing to Apache OpenNLP.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [x] Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] Have you ensured that the full suite of tests is executed via mvn clean install at the root opennlp folder?
   - [x] Have you written or updated unit tests to verify your changes?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file in opennlp folder?
   - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found in opennlp folder?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions for build issues and submit an update to your PR as soon as possible.
   


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] kinow commented on a diff in pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #516:
URL: https://github.com/apache/opennlp/pull/516#discussion_r1125562917


##########
opennlp-tools/src/main/java/opennlp/tools/tokenize/lang/Factory.java:
##########
@@ -43,18 +53,25 @@ public class Factory {
    */
   public Pattern getAlphanumeric(String languageCode) {

Review Comment:
   A good idea I think, +1 to both the enum and the jira.



-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] jzonthemtn commented on a diff in pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "jzonthemtn (via GitHub)" <gi...@apache.org>.
jzonthemtn commented on code in PR #516:
URL: https://github.com/apache/opennlp/pull/516#discussion_r1125507009


##########
opennlp-tools/src/main/java/opennlp/tools/tokenize/lang/Factory.java:
##########
@@ -43,18 +53,25 @@ public class Factory {
    */
   public Pattern getAlphanumeric(String languageCode) {

Review Comment:
   At some point would it make sense to have `languageCode` be an enum instead of a string?



-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] mawiesne merged pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, Catalan, and Polish)

Posted by "mawiesne (via GitHub)" <gi...@apache.org>.
mawiesne merged PR #516:
URL: https://github.com/apache/opennlp/pull/516


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] kinow commented on pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on PR #516:
URL: https://github.com/apache/opennlp/pull/516#issuecomment-1455047303

   > @kinow Could you open an issue for adding pattern verification tests per language we include? Each (parameterized) test should include some typical (rare) examples specific to that language.
   
   Done! https://issues.apache.org/jira/browse/OPENNLP-1479


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] kinow commented on pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on PR #516:
URL: https://github.com/apache/opennlp/pull/516#issuecomment-1454895458

   Just going to test something and see if I can suggest another language, then will review it :+1: 


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] kinow commented on a diff in pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #516:
URL: https://github.com/apache/opennlp/pull/516#discussion_r1125635587


##########
opennlp-tools/src/main/java/opennlp/tools/tokenize/lang/Factory.java:
##########
@@ -30,10 +30,27 @@ public class Factory {
   private static final Pattern PORTUGUESE = Pattern.compile("^[0-9a-záãâàéêíóõôúüçA-ZÁÃÂÀÉÊÍÓÕÔÚÜÇ]+$");
   private static final Pattern FRENCH = Pattern.compile("^[a-zA-Z0-9àâäèéêëîïôœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ]+$");
 
-  // For reference: https://www.sttmedia.com/characterfrequency-dutch
+  // From: https://www.sttmedia.com/characterfrequency-dutch
   private static final Pattern DUTCH = Pattern.compile("^[A-Za-z0-9äöüëèéïijÄÖÜËÉÈÏIJ]+$");
-  private static final Pattern GERMAN = Pattern.compile("^[A-Za-z0-9äöüÄÖÜß]+$");
 
+  // Note: The extra é and É are included to cover German "Lehnwörter" such as "Café"
+  private static final Pattern GERMAN = Pattern.compile("^[A-Za-z0-9äéöüÄÉÖÜß]+$");
+
+  // From: https://en.wikipedia.org/wiki/Polish_alphabet
+  //       https://pl.wikipedia.org/wiki/Alfabet_polski
+  private static final Pattern POLISH = Pattern.compile("^[A-Za-z0-9żźćńółęąśŻŹĆĄŚĘŁÓŃ]+$");

Review Comment:
   Just my OCD here, @mawiesne , but could we keep the same order for lower case and upper case? :grimacing: 
   
   s/A-Za-z0-9żźćńółęąśŻŹĆĄŚĘŁÓŃ/A-Za-z0-9żźćąśęłóńŻŹĆĄŚĘŁÓŃ (I was reading the upper case as "alphanum and Z Z Caselon", and thought it was an easy way to memorize it, so went with that for the lower case chars too, but we can change it if that makes more sense)



-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] kinow commented on a diff in pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #516:
URL: https://github.com/apache/opennlp/pull/516#discussion_r1125562917


##########
opennlp-tools/src/main/java/opennlp/tools/tokenize/lang/Factory.java:
##########
@@ -43,18 +53,25 @@ public class Factory {
    */
   public Pattern getAlphanumeric(String languageCode) {

Review Comment:
   A good idea I think, +1 to both the enum and the jira (probably an epic, especially if we need to update sandbox components).



-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] mawiesne commented on pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "mawiesne (via GitHub)" <gi...@apache.org>.
mawiesne commented on PR #516:
URL: https://github.com/apache/opennlp/pull/516#issuecomment-1455041161

   @kinow I added the Catalan and Polish regex. Please share your feedback if we are good to 🚀  with this PR.


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] mawiesne commented on a diff in pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "mawiesne (via GitHub)" <gi...@apache.org>.
mawiesne commented on code in PR #516:
URL: https://github.com/apache/opennlp/pull/516#discussion_r1125508756


##########
opennlp-tools/src/main/java/opennlp/tools/tokenize/lang/Factory.java:
##########
@@ -43,18 +53,25 @@ public class Factory {
    */
   public Pattern getAlphanumeric(String languageCode) {

Review Comment:
   Feel free to open a Jira _epic_ (or single issue?) for this improvement and share a list of languages most widely used by OpenNLP's users. As a start, this `Factory` might cover most.



-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [opennlp] mawiesne commented on pull request #516: OPENNLP-1474 Create tokenizer factories for other langs (Spanish, Italian, ...)

Posted by "mawiesne (via GitHub)" <gi...@apache.org>.
mawiesne commented on PR #516:
URL: https://github.com/apache/opennlp/pull/516#issuecomment-1455015772

   > What do you think about adding Catalan too, @mawiesne ?
   
   We can integrate Catalan with PR, I think. Issue title reads open for me. Maybe I'll add a Polish pattern as well, later today.
   
   However: 
   @kinow Could you open an issue for adding pattern verification tests per language we include? Each (parameterized) test should include some typical (rare) examples specific to that language.


-- 
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: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org