-
Notifications
You must be signed in to change notification settings - Fork 7
Add natural translation for DSL #574
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
Open
BrentBlanckaert
wants to merge
113
commits into
master
Choose a base branch
from
feat/add-natural-translation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 106 commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
d1a544b
Made first version for translation using !natural_language
BrentBlanckaert d0cf7de
forgot to push actual file
BrentBlanckaert 0334e1f
fixed linting
BrentBlanckaert c1114bc
fixed pyright issue
BrentBlanckaert c61b563
add test for unit-test
BrentBlanckaert 145deae
Fixed some bugs and wrote another test for io
BrentBlanckaert e14c758
setup main
BrentBlanckaert 65fb097
Made a small fix
BrentBlanckaert e941ef6
Tested an extra edge case
BrentBlanckaert eef397b
Cleaned up code and added extra cases.
BrentBlanckaert 30bcdcc
Started on usage with translation table.
BrentBlanckaert 4230003
Added support for translation-table in global scope, tab-scope and co…
BrentBlanckaert 1ddef15
Cleaned up code and fixed pyright issue
BrentBlanckaert 5dabc80
fixed tests and added more
BrentBlanckaert 69a77d3
fixed some small issues
BrentBlanckaert eb62f92
made some small fixes
BrentBlanckaert 6e258cf
wrote an extra test
BrentBlanckaert 1db1db2
fix spelling mistake
BrentBlanckaert 4dedd8c
fixed linting issue
BrentBlanckaert b9786c2
increasing test coverage
BrentBlanckaert c63e391
removed some redundant code
BrentBlanckaert a35c49a
Adding a few comments
BrentBlanckaert 10b0eb3
Cleaned up code some more and added extra cases for input and output …
BrentBlanckaert 3539227
Updated statement/expression case and added programmingLanguageMap fo…
BrentBlanckaert e1180f9
started added new json schema
BrentBlanckaert 466ec16
Made some changes to schema
BrentBlanckaert 49079a0
fixed some bugs in the schema
BrentBlanckaert 4174beb
fixed some bugs and fixed the tests
BrentBlanckaert 1a79a82
fixed an edge case and made an extra test for it.
BrentBlanckaert 81ce161
added the actual writing to a file.
BrentBlanckaert 64a00cd
changed formatter to jinja
BrentBlanckaert 88a2ede
small cleanup
BrentBlanckaert e6e548c
moved tests to new file
BrentBlanckaert 95f8524
Small cleanup
BrentBlanckaert 9ac66cb
fix isort
BrentBlanckaert b7012d3
got rid of usage of instanceof
BrentBlanckaert f630a05
fixed test
BrentBlanckaert a5d7f61
Made small variable name change
BrentBlanckaert 1b9775d
rewrote the pre-processor
BrentBlanckaert fe62210
fixed tests
BrentBlanckaert dec7057
removed some prints
BrentBlanckaert 94ea109
cleaned up the code some more
BrentBlanckaert c75d4a7
fixed linting issue and removed more redundant code.
BrentBlanckaert 7dac7d6
Removed some checks that are no longer used
BrentBlanckaert 86c6421
Wat comments toegevoegd
BrentBlanckaert e2d9d69
gebruik van instanceof zoveel mogelijk vermeden
BrentBlanckaert 9a540a6
Fixed linting en typing
BrentBlanckaert c7d5787
removed an unused field.
BrentBlanckaert 7681932
Fixed small bug
BrentBlanckaert 820c36a
Changed a name
BrentBlanckaert eecc7b1
Merged all translations maps immediately
BrentBlanckaert 14e16db
re-added validator
BrentBlanckaert 885aa48
Fixed typing issues
BrentBlanckaert d06a55c
added test for error handling
BrentBlanckaert b7c8c34
added an extra test for syntax errors
BrentBlanckaert 470e28c
fix linting
BrentBlanckaert 94a766f
Added immediate link from preprocessor to tested.
BrentBlanckaert 4629134
Fixed bug for a lot of tests
BrentBlanckaert f9d311d
Small cleanup
BrentBlanckaert f7c65cb
made a few more tests
BrentBlanckaert a539053
fixed linting issues
BrentBlanckaert c72190c
fixed small issue regarding lists of tabs
BrentBlanckaert 0959919
removed field to serves no purpose anymore
BrentBlanckaert 8aee618
fixed linting
BrentBlanckaert f668535
Found another edge case that wasn't covered
BrentBlanckaert b62bfc3
using pythonic code
BrentBlanckaert 9f4a84f
Fixed a small bug with the nat_lang_indicators
BrentBlanckaert 23d9b01
Added another check
BrentBlanckaert e78c518
Fxed linting
BrentBlanckaert 3ed7491
forgot a tab
BrentBlanckaert 2027194
fixed problem when no translations are used
BrentBlanckaert 9055b90
kleine optimalisatie
BrentBlanckaert 3f20d10
Made attempt for stdout/stderr
BrentBlanckaert 7952b2d
made new version for translations
BrentBlanckaert 3e9f27a
used a different way to convert to yamlObject
BrentBlanckaert fc6dbc5
cleaned up code
BrentBlanckaert cbcb263
test why it test don't work in github
BrentBlanckaert 16f5527
adding more prints
BrentBlanckaert f4c55d7
adding more prints
BrentBlanckaert d9c115b
trying something else
BrentBlanckaert 77fbf13
revert back
BrentBlanckaert 35cf415
added test and cleaned up some of the code
BrentBlanckaert d2fb379
added extra test for conversion to yamlObject
BrentBlanckaert 9ff38b5
made an extra test
BrentBlanckaert 361aa5c
made one more test
BrentBlanckaert b81e152
fix linting
BrentBlanckaert fc7258e
Major cutback of of TESTed in translation
BrentBlanckaert 18fbd02
forgot to push actual new file
BrentBlanckaert e86d48a
split up tests
BrentBlanckaert 4289910
Fixed linting and typing issues
BrentBlanckaert 33ba90f
Fixed ALL linting issues
BrentBlanckaert 204f50a
applied all changes regarding jinja2
BrentBlanckaert 9c83b4d
Added an extra test
BrentBlanckaert 29b3a45
removed conversion to yamlObject
BrentBlanckaert 4f0a0ca
remove unused import
BrentBlanckaert 84fb41f
got rid of the !programming_language tag for this PR
BrentBlanckaert 57fcc0e
Made an extra test
BrentBlanckaert c7cde3d
Fix linting
BrentBlanckaert 79210fa
Give warning for each missing key
BrentBlanckaert d62862a
Merge branch 'master' of https://github.com/dodona-edu/universal-judge
BrentBlanckaert 2c9bc06
added a bit of documentation and did some last changes to Json schema
BrentBlanckaert 502f51d
removing redundant line
BrentBlanckaert 52537f6
fixed linting
BrentBlanckaert 511d6cf
cleaned up code some more and added asserts
BrentBlanckaert 71c9ee5
merging with master
BrentBlanckaert c11df03
changing main
BrentBlanckaert f327e19
fixed a few issues
BrentBlanckaert 5cd9e15
remove unused import
BrentBlanckaert 1d40776
fixing typing issue
BrentBlanckaert 3a97b15
made few changes
BrentBlanckaert bb3438e
removed default from arguments
BrentBlanckaert f09f925
changed some of the names
BrentBlanckaert 46ea4cc
fixed linting
BrentBlanckaert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import sys | ||
import textwrap | ||
|
||
import yaml | ||
from jsonschema.exceptions import ValidationError | ||
|
||
|
||
class InvalidYamlError(ValueError): | ||
pass | ||
|
||
|
||
class DslValidationError(ValueError): | ||
pass | ||
|
||
|
||
def convert_validation_error_to_group( | ||
error: ValidationError, | ||
) -> ExceptionGroup | Exception: | ||
if not error.context and not error.cause: | ||
if len(error.message) > 150: | ||
message = error.message.replace(str(error.instance), "<DSL>") | ||
note = "With <DSL> being: " + textwrap.shorten(str(error.instance), 500) | ||
else: | ||
message = error.message | ||
note = None | ||
converted = DslValidationError( | ||
f"Validation error at {error.json_path}: " + message | ||
) | ||
if note: | ||
converted.add_note(note) | ||
return converted | ||
elif error.cause: | ||
return error.cause | ||
elif error.context: | ||
causes = [convert_validation_error_to_group(x) for x in error.context] | ||
message = f"Validation error at {error.json_path}, caused by a sub-exception." | ||
return ExceptionGroup(message, causes) | ||
else: | ||
return error | ||
|
||
|
||
def handle_dsl_validation_errors(errors: list): | ||
if len(errors) == 1: | ||
message = ( | ||
"Validating the DSL resulted in an error. " | ||
"The most specific sub-exception is often the culprit. " | ||
) | ||
error = convert_validation_error_to_group(errors[0]) | ||
if isinstance(error, ExceptionGroup): | ||
raise ExceptionGroup(message, error.exceptions) | ||
else: | ||
raise DslValidationError(message + str(error)) from error | ||
elif len(errors) > 1: | ||
the_errors = [convert_validation_error_to_group(e) for e in errors] | ||
message = "Validating the DSL resulted in some errors." | ||
raise ExceptionGroup(message, the_errors) | ||
|
||
|
||
def raise_yaml_error(yaml_stream: str, exc: yaml.MarkedYAMLError): | ||
lines = yaml_stream.splitlines() | ||
|
||
if exc.problem_mark is None: | ||
# There is no additional information, so what can we do? | ||
raise exc | ||
|
||
sys.stderr.write( | ||
textwrap.dedent( | ||
f""" | ||
YAML error while parsing test suite. This means there is a YAML syntax error. | ||
|
||
The YAML parser indicates the problem lies at line {exc.problem_mark.line + 1}, column {exc.problem_mark.column + 1}: | ||
|
||
{lines[exc.problem_mark.line]} | ||
{" " * exc.problem_mark.column + "^"} | ||
|
||
The error message was: | ||
{exc.problem} {exc.context} | ||
|
||
The detailed exception is provided below. | ||
You might also find help by validating your YAML file with a YAML validator.\n | ||
""" | ||
) | ||
) | ||
raise exc |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.