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

add JSONTransformer #35

Merged
merged 5 commits into from Jun 14, 2019
Merged

add JSONTransformer #35

merged 5 commits into from Jun 14, 2019

Conversation

dwinston
Copy link
Contributor

Closes #26.

Example in:

"a<3 and b>4"

Example out:

{'@module': 'lark', '@class': 'Tree', 'data': 'start', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'expression', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'term', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'term', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'atom', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'comparison', 'children': [{'@module': 'lark.lexer', '@class': 'Token', 'type_': 'VALUE', 'value': 'a'}, {'@module': 'lark.lexer', '@class': 'Token', 'type_': 'OPERATOR', 'value': '<'}, {'@module': 'lark.lexer', '@class': 'Token', 'type_': 'VALUE', 'value': '3'}]}]}]}, {'@module': 'lark.lexer', '@class': 'Token', 'type_': 'CONJUNCTION', 'value': 'and'}, {'@module': 'lark', '@class': 'Tree', 'data': 'atom', 'children': [{'@module': 'lark', '@class': 'Tree', 'data': 'comparison', 'children': [{'@module': 'lark.lexer', '@class': 'Token', 'type_': 'VALUE', 'value': 'b'}, {'@module': 'lark.lexer', '@class': 'Token', 'type_': 'OPERATOR', 'value': '>'}, {'@module': 'lark.lexer', '@class': 'Token', 'type_': 'VALUE', 'value': '4'}]}]}]}]}]}

@dwinston dwinston requested a review from ltalirz June 13, 2019 16:28
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

very cool!
let's perhaps try to make a bit clearer how this could be used as part of a pipeline written in a different programming language (see comment)

README.md Outdated
@@ -127,6 +127,46 @@ print(query)
{'$and': [{'_mp_bandgap': {'$gt': 5.0}}, {'_cod_molecular_weight': {'$lt': 350.0}}]}
```

There is also a basic JSON transformer (`optimade.filtertransformers.json.JSONTransformer`) you can use as an
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There is also a basic JSON transformer (`optimade.filtertransformers.json.JSONTransformer`) you can use as an
There is also a [basic JSON transformer](optimade/filtertransformers/json.py) (`optimade.filtertransformers.json.JSONTransformer`) you can use as a simple example for developing your own transformer.
You can also use the JSON output it produces as easy-to-parse input for a "transformer" in your programming language of choice.

@ltalirz
Copy link
Member

ltalirz commented Jun 14, 2019

I'll do the fix myself.

@ltalirz ltalirz self-requested a review June 14, 2019 09:47
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks, let's merge this!

@ltalirz ltalirz merged commit 4c7e3ac into master Jun 14, 2019
@CasperWA CasperWA deleted the jsontransformer branch November 8, 2019 14:36
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.

write a lark JSONTransformer / JSONdecoder
2 participants