Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update owcorpus.py #1083

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update owcorpus.py #1083

wants to merge 1 commit into from

Conversation

jcmhk
Copy link

@jcmhk jcmhk commented Sep 19, 2024

if you create an ows file containing a corpus on one computer and open it on another, it happens that the second PC does not find the language and displays an error message in a loop. This PR allows you to load the workflow on the second PC.

if language not found continu

Issue
Description of changes
Includes
  • Code changes
  • Tests
  • Documentation

if language not found continu
@ajdapretnar ajdapretnar requested a review from janezd January 15, 2025 09:29
@ajdapretnar
Copy link
Collaborator

@janezd Could you please have a look, since context migrations are your thing?

@janezd
Copy link
Contributor

janezd commented Jan 15, 2025

@jcmhk, thank you for you contribution.

I don't know much about the text add-on, I can comment from perspective of settings (and code).

I think this would be better:

               language, type_ = context.values["language"]
               migr_language = migrate_language_name(language)
               try:
                   language = LANG2ISO[migr_language]
               except KeyError:
                   pass
               else:
                   context.values["language"] = (language, type_)

I supposed that the try-except clause is here for the case that language is not in LANG2ISO. If so, this is the only line that should be within try. Furthermore, except should only catch KeyError and not anything that can go wrong and we haven't thought about.

However, if the only thing that can go wrong is a missing key, the correct code is

               language, type_ = context.values["language"]
               migr_language = migrate_language_name(language)
               if migr_language in LANG2ISO: 
                   language = LANG2ISO[migr_language]
                   context.values["language"] = (language, type_)

I removed the print; you should show a message by calling warning, but we usually don't show warning in migrations.

I removed return because other migrations may follow in the future.

As said, I don't know what the widget is about and what this setting does. It's just a general remark about the code.

One thing that is missing is setting a default if migration fails, that is, is the current setting is incorrect and you can't fix it. I don't know enough about the widget to suggest anything, so I'm passing the ball back to @ajdapretnar. :)

@ajdapretnar
Copy link
Collaborator

I think it would be best if the default language was English. The setting should not affect the user-based settings else, just take care of defaults. Or it could be Afrikaans (alphabetically first), even though it would be better to have English as a default since it is the most widely used in NLP.

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.

3 participants