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

Implement CLI --total functionality #162

Merged
merged 9 commits into from
Jul 25, 2024
Merged

Conversation

mhmohona
Copy link
Member

Contributor checklist


Description

Implemented the --total (-t) functionality would check Wikidata for the total of certain groupings of languages and word types.

image

Related issue

Fixes - #147

Copy link

github-actions bot commented Jun 26, 2024

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Data rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you!

Maintainer checklist

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution

    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local Scribe-Data repo
  • The linting and formatting workflow within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@mhmohona
Copy link
Member Author

It still has a problem. It is recognizing data-type as language like this -
image

@mhmohona mhmohona changed the title Add CLI --total functionality Implement CLI --total functionality Jun 26, 2024
@andrewtavis
Copy link
Member

Any thoughts on what's causing it, @mhmohona? :)

}

# Dictionary to map data types to their Wikidata Q-IDs
data_type_to_qid = {
Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewtavis will you please check here if I have the correct QID?

@andrewtavis
Copy link
Member

Minor comments so far:

  • Let's include the language and the data type in the output
  • From @wkyoshida, something like:
Language: German
Data type: Verbs
Total number of lexemes: 999
  • Let's move data_type_to_qid to the data_type_metadata.json file
  • Let's reference the language_metadata.json file for the language_to_qid information

We'll be good to go after all this! 🥳

@andrewtavis
Copy link
Member

Quick check here @mhmohona, are you planning on getting to the changes we mentioned above?

@wkyoshida
Copy link
Member

It still has a problem. It is recognizing data-type as language like this - image

Doesn't this work since -l German is passed first? Could just be that the first argument is recognized and used. The second may have been passed, but it's disregarded.

Looks like there is a choices parameter that we can pass in to add_argument() to specify what are the allowable options for an argument. Maybe we look if specifying this could make sense as the mechanism for controlling valid/invalid inputs?

@mhmohona
Copy link
Member Author

Currently stuck in this comment 😢

Let's move data_type_to_qid to the data_type_metadata.json file

@andrewtavis
Copy link
Member

By this I mean let's move the functionality of data_type_to_qid to the data_type_metadata.json file such that we just import the data at the top of the file rather than using a custom function :)

@mhmohona
Copy link
Member Author

It still has a problem. It is recognizing data-type as language like this - image

Doesn't this work since -l German is passed first? Could just be that the first argument is recognized and used. The second may have been passed, but it's disregarded.

Looks like there is a choices parameter that we can pass in to add_argument() to specify what are the allowable options for an argument. Maybe we look if specifying this could make sense as the mechanism for controlling valid/invalid inputs?

@wkyoshida, thank you for looking into it. I have solved this problem.

@mhmohona
Copy link
Member Author

By this I mean let's move the functionality of data_type_to_qid to the data_type_metadata.json file such that we just import the data at the top of the file rather than using a custom function :)

I need help with the QID. :( Unable to find the correct QIDs. It would be super helpful for me if you would update the data_type_metadata.json file with QIDs @andrewtavis.

@mhmohona
Copy link
Member Author

I

Minor comments so far:

  • Let's include the language and the data type in the output
  • From @wkyoshida, something like:
Language: German
Data type: Verbs
Total number of lexemes: 999
  • Let's move data_type_to_qid to the data_type_metadata.json file
  • Let's reference the language_metadata.json file for the language_to_qid information

We'll be good to go after all this! 🥳

I have addressed 1st and 3rd feedback from here.

image

@mhmohona mhmohona requested review from andrewtavis July 11, 2024 09:31
@@ -127,7 +128,11 @@ def main() -> None:
)
total_parser._actions[0].help = "Show this help message and exit."
total_parser.add_argument(
"-lang", "--language", type=str, help="The language(s) to check totals for."
"-l",
Copy link
Member

Choose a reason for hiding this comment

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

I'm going to remove -l as an option, @mhmohona, as I think that making sure that we don't have commands and arguments that are the same is important :)

@@ -190,7 +195,13 @@ def main() -> None:
)

elif args.command in ["total", "t"]:
return
if not args.language and not args.data_type:
Copy link
Member

Choose a reason for hiding this comment

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

Really appreciate the quality of your messages to the user, @mhmohona!

"Error: At least one of -lang/--language or -dt/--data-type must be specified."
)
total_parser.print_help()
return
Copy link
Member

Choose a reason for hiding this comment

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

Let's always do a space after return :)

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

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

Thanks so much for this, @mhmohona! The full experience of Scribe-Data is really coming along 😊

@andrewtavis andrewtavis merged commit 1bd659d into scribe-org:main Jul 25, 2024
2 checks passed
@mhmohona mhmohona deleted the total branch August 28, 2024 01:28
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