post_eval

post_eval #

Synonyms are drawn during the write_text processing so you won’t have access to the chosen synonym when you write your text structure.

As you build complex sentences, you’ll want to know which word was chosen as a synonym to match the end of the sentence with it.

Use post_eval to check the activation of keys which may have been previously activated when drawing synonyms.

nlg = NlgTools()

text = TextVar(

  'I decided to eat',

  nlg.nlg_syn(
    'one',
    ('three', 'PLURAL')
  ),

  nlg.post_eval('PLURAL', 'apples', 'apple', True),

  '.'
)

nlg.write_text(text)

# This will give you either "I decided to eat one apple." or "I decided to eat three apples."
# The 'PLURAL' key is now deactivated so next post_eval method would not find it.

Parameters #

ParameterTypeDefault Value
The key to checkString
The text to write if the key is foundString""
The text to write if the key not foundString""
Should the key be deactivated if foundBooleanFalse
non_reg_id Id for non regression testingStringThe hash of the object data

Return #

The post_eval method returns a string containing a token. This string should be evaluated by the write_text method of the NlgTools object to replace the token with the correct text.