Natural Language Generation¶
SemOManager.py - Semantic Output¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import utils.Settings
import ontology.OntologyUtils
import utils.ContextLogger
-
class
semo.SemOManager.
SemO
¶ Interface class for a single domain langauge generator. Responsible for generating a natural langauge sentence from a dialogue act representation. To create your own SemO methods, derive from this class.
-
generate
(act)¶ Main generation method: mapping from system act to natural language :param act: the system act to generate :type act: str :returns: the natural language realisation of the given system act
-
-
class
semo.SemOManager.
SemOManager
¶ SemO manager for each domain. Independently for each domain you can load a generator. Implementations of actual generators are in other modules
-
_ensure_booted
(domainTag)¶ - The function to ensure the given domain generator is properly loaded
param domainTag: the domain string unique identifier, the domain you operate on.
-
_load_domains_semo
(dstring)¶ Get from the config file the SemO choice of method for this domain
-
generate
(act, domainTag=None)¶ Main generation method which maps the given system act into natural langauge realisation. :param domainTag: the domain string unique identifier, the domain you operate on. :act: the system act you want to generate
-
RuleSemOMethods.py - Classes for all Rule based Generators¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import semo.SemOManager
import utils.Settings
import utils.DiaAct
import utils.dact
import utils.ContextLogger
import ontology.OntologyUtils
-
class
semo.RuleSemOMethods.
PassthroughSemO
¶ Does nothing - simply pass system act directly through.
-
class
semo.RuleSemOMethods.
BasicSemO
(domainTag=None)¶ Template-based output generator. Note that the class inheriting from object is important - without this the super method can not be called – This relates to ‘old-style’ and ‘new-style’ classes in python if interested …
Parameters: - templatefile ([basicsemo]) – The template file to use for generation.
- emphasis ([basicsemo]) – Generate emphasis tags.
- emphasisopen ([basicsemo]) – Emphasis open tag (default: <EMPH<).
- emphasisclose ([basicsemo]) – Emphasis close tag (default: </EMPH<).
-
class
semo.RuleSemOMethods.
BasicTemplateRule
(scanner)¶ The template rule corresponds to a single line in a template rules file. This consists of an act (including non-terminals) that the rule applies to with an output string to generate (again including non-terminals). Example:
select(food=$X, food=dontcare) : "Sorry would you like $X food or you dont care"; self.rue_items = {food: [$X, dontcare]}
-
class
semo.RuleSemOMethods.
BasicTemplateFunction
(scanner)¶ A function in the generation rules that converts a group of inputs into an output string. The use of template functions allows for simplification of the generation file as the way a given group of variables is generated can be extended over multiple rules.
The format of the function is:
%functionName($param1, $param2, ...) { p1, p2, ... : "Generation output";}
Parameters: scanner (instance) – of Scanner
-
class
semo.RuleSemOMethods.
BasicTemplateFunctionRule
(scanner)¶ A single line of a basic template function. This does a conversion of a group of values into a string. e.g. p1, p2, … : “Generation output”
Parameters: scanner (instance) – of Scanner
-
class
semo.RuleSemOMethods.
BasicTemplateGenerator
(filename)¶ The basic template generator loads a list of template-based rules from a string. These are then applied on any input dialogue act and used to generate an output string.
Parameters: filename (str) – the template rules file
RNNSemOMethods.py - Interface for all RNN based Generators¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import semo.SemOManager
import semo.RuleSemOMethods
import semo.RNNLG.generator.net
import utils.Settings
import utils.ContextLogger
-
class
semo.RNNSemOMethods.
RNNSemO
(domainTag=None)¶ An interface for RNN-based output generator.
Parameters: - configuration ([rnnsemo]) – The config file to use for initialising RNNLG
- template file ([rnnsemo]) – The template file for a default rule-based generator. This rule based generator is used when the RNN generator cannot generate sensible sentences.