gramener / gramex-nlg

Natural Language Generation for Gramex applications.
Other
24 stars 24 forks source link

Templatize comparative adjectives with respect to sort order. #38

Open jaidevd opened 4 years ago

jaidevd commented 4 years ago

In context of the actors dataset,

doc = nlp('James Stewart has the highest rating.')
fh_args = {'_sort': ['-rating']}
nugget = templatize(doc, fh_args, df)
print(nugget)
{% set fh_args = {"_sort": ["-rating"]}  %}
{% set df = U.gfilter(orgdf, fh_args.copy()) %}
{% set fh_args = U.sanitize_fh_args(fh_args, orgdf) %}
{# Do not edit above this line. #}
{{ df["name"].iloc[0] }} is the {{ G.singular(df["category"].iloc[-2]).lower() }} with the highest rating.

The adjective highest should be templatized in the following manner:

  1. Find its lemma and inflected form and put them in a variable.
  2. Tie the lemma to the sort order.
  3. Automatically insert the antonym of the lemma if the sort order changes.
jaidevd commented 4 years ago

See this gist for some initial examples of getting antonyms with wordnet.