Nuggets should have a .clone() method, which copies a nugget but assigns a different set of FormHandler arguments. This would help auto-generate new nuggets.
fh_args = {'_sort': ['-rating']}
doc = nlp('James Stewart is the actor who has the highest rating.')
nugget = nlg.templatize(doc, fh_args, df)
new_nugget = nugget.clone({'_sort': ['rating']}) # note the change in sort order
new_nugget.render(df)
# Katharine Hepburn is the actress who has the highest rating.
CAUTION: This will only work correctly if all tokens have been properly templatized. Note that the token "highest", left un-templatized, stays as it is even when the order of sorting changes. In this case, the token will have to be made sensitive to the sorting order (see #38) . But generally, any token left un-templatized may get affected.
Nuggets should have a
.clone()
method, which copies a nugget but assigns a different set of FormHandler arguments. This would help auto-generate new nuggets.E.g, in the context of the actors dataset
CAUTION: This will only work correctly if all tokens have been properly templatized. Note that the token
"highest"
, left un-templatized, stays as it is even when the order of sorting changes. In this case, the token will have to be made sensitive to the sorting order (see #38) . But generally, any token left un-templatized may get affected.