Semantic Parsing¶
SemI.py - Semantic input parser¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import ontology.OntologyUtils
import semi.SemIContextUtils
import utils.Settings
import utils.ContextLogger
- class semi.SemI.SemI¶
Interface class SemI, it defines the method decode that all the SemI classes must implement
- decode(ASR_obs, sys_act=None, turn=None)¶
The main interface method for semantic decoding. It takes the ASR input and returns a list of semantic interpretations.
This method must be implemented by a sub-class.
- Parameters
ASR_obs – the ASR observation list
ASR_obs – list
sys_act – the last system action, optional
sys_act – str
turn – the current turn number, optional
turn – int
- Returns
list of semantic interpretations of the input
- class semi.SemI.SemIManager¶
The Semantic Input Manager contains a dictionary with all the SemI objects currently running, the key of the dictionary is the domain tag
- _ensure_booted(domainTag)¶
Boots up the semi ability for the specified domain if required
- Parameters
domainTag (str) – domain description
- Returns
None
- _load_domains_semi(dstring)¶
Get from the config file the SemI choice of method for this domain and load it. If you want to add a new semantic input parser you must add a line in this method calling explicitly the new SemI class, that must inherit from SemI
- Parameters
dstring (str) – the name of the domain
- Returns
the class with the SemI implementation
- clean_possible_texthub_switch(userActText)¶
NB: only for texthub.py
This removes switch(“Domain”) - as you may enter in texthub if using the switch topic tracker You can add domain information after e.g.: switch(“CamRestaurants”)i want a cheap restaurant
- Parameters
userActText – list of user act hypothesis?
- Returns
- decode(ASR_obs, sys_act, domainTag, turn=None)¶
The main method for semantic decoding. It takes the ASR input and returns a list of semantic interpretations. To decode, the task is delegated to the respective domain semantic decoder
- Parameters
ASR_obs (list) – ASR hypotheses
sys_act (str) – is the system action prior to collecting users response in obs.
domainTag (str) – is the domain we want to parse the obs in
turn (int) – the turn id, this parameter is optional
- Returns
None
- simulate_add_context_to_user_act(sys_act, user_acts, domainTag)¶
NB: only for Simulate.py
While for simulation no semantic decoding is needed, context information needs to be added in some instances. This is done with this method.
- Parameters
sys_act (str) – the last system act
user_acts (list) – user act hypotheses
domainTag (str) – the domain of the dialogue
RuleSemIMethods.py - Semantic input parsers based on rules¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import utils.ContextLogger
import semi.RegexSemI_generic.RegexSemI_generic
Collection of Semantic Parsers that are rule based.
- class semi.RuleSemIMethods.PassthroughSemI¶
Does nothing - simply pass observation directly through (on assumption that observation was a semantic act input by a texthub user) – hence is domain independent and doesn’t need a manager
- class semi.RuleSemIMethods.RegexSemI(domainTag)¶
A semantic parser based on regular expressions. One parser for each domain is necessary. To implement a new regex parser, derive from semi.RegexSemI.RegexSemI and create your own module called “RegexSemI_<yourdomainname>” containing the class “RegexSemI_<yourdomainname>”.
RegexSemI.py - Regular expressions SemI parser base class¶
Note
This implementation is based on the following assumptions:
obs can be a ASR n-best list - potential sentence inputs each with a probability (Currently - no probabilities - will have to slightly amend code to deal with these.)
will only output text semantic acts (plus probs maybe) – wont be instances of DiaAct for example
Warning
Remember that this is the base class for all of the regex parsers. Making changes here could possibly fix a parser in your domain, but (at worst!) break/weaken parsers in all other domains! i.e. – 1st, 2nd and 3rd approaches should be to tweak the derived class for the domain of interest. You can redefine anything in the derived class.
See also
CUED Imports/Dependencies:
import utils.Settings
import semi.SemI.SemI
import semi.SemIContextUtils
import ontology.Ontology
- class semi.RegexSemI.RegexSemI¶
Is a base class for each domains Regular Expressions based semantic parser. Primary focus is on users intent. The derived semantic parsers of each domain can deal with the constraints (slots,values).