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

Intermediate representation of FormHandler arguments #18

Closed
jaidevd opened this issue Jan 17, 2020 · 1 comment
Closed

Intermediate representation of FormHandler arguments #18

jaidevd opened this issue Jan 17, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jaidevd
Copy link
Member

jaidevd commented Jan 17, 2020

Do not tokenize / process / search formhandler arguments as they are. Leading hyphens cause the tokens to get corrupted. For example:

>>> df = pd.read_csv('actors.csv')
>>> fh_args = {'_sort': ['-rating']}
>>> text = nlp('James Stewart is the actor with the highest rating.')
>>> n = templatize(text, fh_args, df)
>>> n.render(df)
b'James Stewart is the actor with the highest -rating.'

Instead, preprocess FormHandler arguments with gramex.data._filter_{sort, select, groupby}_columns to get a cleaner representation which leaves the token untouched. Use this representation in the template.

@jaidevd jaidevd added the bug Something isn't working label Jan 17, 2020
@jaidevd jaidevd added this to the Python module beta release milestone Jan 17, 2020
@jaidevd jaidevd self-assigned this Jan 17, 2020
@jaidevd
Copy link
Member Author

jaidevd commented Jan 17, 2020

This should also handle any other FormHandler DSL artifacts, like pipes:

fh_args = {'_by': ['species'], '_c': ['sepal_width|avg'], '_sort': ['sepal_width|avg']}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant