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

refactor and modify query forms #492

Merged
merged 2 commits into from
Oct 27, 2024
Merged

Conversation

axif0
Copy link
Contributor

@axif0 axif0 commented Oct 27, 2024

Contributor checklist


Description

what I understand is check_forms_order are taking the lemma of the lexeme in select statement. it checks dt_pattern and forms_pattern in where clause. if the select_vars[0] !=where_vars[0] then it only gives the error of order of variables in the SELECT statement does not match their order in the query.

Basically check_undefined_return_forms and check_defined_return_forms are for checking Unreturned forms. If a form are present in while clause but not stated in select statement, it gives error like Unreturned forms {form-name}.

We can marge the overall functionalities into one function at once.

I have a confution in lexeme_form_metadata.json, the levels are missing like if I add verbsTest in select statement and also in where clause, it should check the metadata file for lebel if lemma is there or not, if not should rise error. Is it what we wanted?

Related issue

Related PR

Check select where labels order #481

Copy link

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

@andrewtavis andrewtavis self-requested a review October 27, 2024 09:45
@andrewtavis andrewtavis added the hacktoberfest-accepted Accepted as a part of Hacktoberfest label Oct 27, 2024
@OmarAI2003
Copy link
Contributor

what I understand is check_forms_order are taking the lemma of the lexeme in select statement. it checks dt_pattern and forms_pattern in where clause. if the select_vars[0] !=where_vars[0] then it only gives the error of order of variables in the SELECT statement does not match their order in the query.

Well, the check_forms_order checks if all the variables (whether they are data types like nouns or any kind of possible form) in the select clause are the same as those in the where clause and in the same order.

present in while clause

There is no while clause in SPARQL

Basically check_undefined_return_forms and check_defined_return_forms are for checking Unreturned forms. If a form are present in while clause but not stated in select statement, it gives error like Unreturned forms {form-name}.

Also for the function check_forms_order If a variable is present in the WHERE clause and not returned in select or the opposite. check_forms_order also catches this error and returns it in the error output here

I have a confution in lexeme_form_metadata.json, the levels are missing like if I add verbsTest in select statement and also in where clause, it should check the metadata file for lebel if lemma is there or not, if not should rise error. Is it what we wanted?

When it comes to this part, it's a bit challenging to check for the labels in the select clause ( that are composed of several grammatical features from the file lexeme_form_metadata.json ) and also check them in order, so ending up with a column name FeminineNominative won't be valid. The good news is I have a solution for this that will be in PR by tomorrow.

@OmarAI2003
Copy link
Contributor

Related PR

Check select where labels order #481

It's strange that GitHub didn't notify me about mentioning a PR I authored 🤯

@axif0
Copy link
Contributor Author

axif0 commented Oct 27, 2024

There is no while clause in SPARQL

Sorry I mean where..

I created a marged both functions and specify which error occurs for which reason. Maybe its more reliable. @OmarAI2003 Can you please check the PR? if it is giving corrected checking?

@OmarAI2003
Copy link
Contributor

I created a marged both functions and specify which error occurs for which reason.

Yeah I can see.

Can you please check the PR? if it is giving corrected checking?

While it's super hard since all the queries are already fixed, I will try 😅

# Check the order of variables in the WHERE and SELECT clauses, and if all forms are defined and returned.
forms_order_and_definition_check = validate_query_forms(query_text)
if forms_order_and_definition_check:
error_output += f"\n{index}. {query_file_str}:\n - {forms_order_and_definition_check}\n"
index += 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Great job on removing your three functions and integrating them into the other function! But, I believe the new function name is too general. one can't distinguish it from the file's main function check_query_forms . What do you think, @andrewtavis?

Copy link
Member

Choose a reason for hiding this comment

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

I'll check this a bit later and see if any renaming is needed based on how it's reading in full :) Thanks for the check @OmarAI2003 and for the work in integrating it all, @axif0!

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.

Thank you for the refactor here, @axif0! Much easier to understand what's going on now :)

@andrewtavis andrewtavis merged commit 8622658 into scribe-org:main Oct 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted as a part of Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants