Ontology¶
DataBase.py - defines the data base interface¶
Copyright CUED Dialogue Systems Group 2015 - 2017
Note
Called by utils.Settings
to load database into global variable db
-
class
ontology.DataBase.
DataBaseINTERFACE
¶ DATA BASE HOLDERS must implement these methods
-
entity_by_features
(constraints)¶ Retrieves from database all entities matching the given constraints.
Parameters: constraints – features. Dict {slot:value, …} or List [(slot, op, value), …] (NB. the tuples in the list are actually a dact
instances)Returns: (list) all entities (each a dict) matching the given features.
-
query_entity_property
(entity, slot, value)¶ This method is needed just because we only pass entity name around at present – would be better to pass entity id around and retireive name when needed - as could wuickly access properties rather than searching … TODO
-
-
ontology.DataBase.
get_dist
(c1, c2)¶ Utility function for calculating the distance between 2 points on Earth.
Parameters: - c1 (2-tuple floats) – latitude,longitude
- c2 (2-tuple floats) – latitude,longitude
Returns: (float) distance
FlatOntologyManager.py - Domain class and Multidomain API¶
Copyright CUED Dialogue Systems Group 2015 - 2017
Controls Access to the ontology files.
See also
CUED Imports/Dependencies:
import utils.Settings
import utils.ContextLogger
import ontology.OntologyUtils
-
class
ontology.FlatOntologyManager.
FlatDomainOntology
(domainString, rootIn=None)¶ Utilities for ontology queries
-
constraintsCanBeDiscriminated
(constraints)¶ Checks if the given constraints list returns a list of values which can be discriminated between - i.e. there is a question which we could ask which would give differences between the values.
-
getRandomValueForSlot
(slot, nodontcare=False, notthese=[], conditional_values=[])¶ Parameters: - slot (str) – None
- nodontcare (bool) – None
- notthese (list) – None
-
getSlotsToExpress
(slot, value)¶ Parameters: - slot –
- value –
Returns: List of slot names that should be conveyed for the given abstract slot-value pair.
-
getValidRequestSlotsForTask
()¶ Parameters: None – Returns: (list) with user requestable goal slot strings Todo
should be extended to cover arbitrary domains and ontologies
-
getValidSlotsForTask
()¶ Parameters: None – Returns: (list) with goal slot strings
-
get_sample_prob
(candidate, conditional_values)¶ Sets a prob distribution over the values in candidate (which could be slots, or values with a slot) - assigns larger probabilities to things within the conditional_values list
Parameters: - candidate (list) – of strings
- conditional_values (list) – of strings
Returns: numpy vector with prob distribution
-
-
class
ontology.FlatOntologyManager.
FlatOntologyManager
¶ A singleton class that is used system wide (single instance created in Ontology.py–>globalOntology) Provides access to all available domains ontologies and databases.
-
constraintsCanBeDiscriminated
(domainString, constraints)¶ Checks if the given constraints list returns a list of values which can be discriminated between - i.e. there is a question which we could ask which would give differences between the values.
-
ensure_domain_ontology_loaded
(domainString)¶
-
getRandomValueForSlot
(dstring, slot, nodontcare=False, notthese=[], conditional_values=[])¶ Randomly select a slot value for the given slot slot.
-
get_discourseAct
(dstring)¶ NB no copy
-
get_informable_slots
(dstring)¶ NB no copy
-
get_informable_slots_and_values
(dstring)¶ NOTE: not using copy.copy() since when used, it is only looped over, not modified
-
get_method
(dstring)¶ NB no copy
-
get_ontology
(dstring)¶ Note: not using copy.copy() – object assumed not to change
-
get_sorted_system_requestable_slots
(dstring, mode='entity')¶ NB no copy
-
is_value_in_slot
(dstring, value, slot)¶
-
Ontology.py - Provides system wide access to ontology¶
Copyright CUED Dialogue Systems Group 2015 - 2017
See also
CUED Imports/Dependencies:
import ontology.FlatOntologyManager
import ontology.OntologyUtils
-
ontology.Ontology.
init_global_ontology
()¶ Should be called ONCE by hubs [texthub, simulate, dialogueserver] (and Tasks when creating) – Then holds the ontology that is used and accessible system wide. Note that the class FlatOntologyManager(object) is a singleton.
-
ontology.Ontology.
init_global_ontology_cer
()¶ Should be called ONCE by hubs [texthub, simulate, dialogueserver] (and Tasks when creating) – Then holds the ontology that is used and accessible system wide. Note that the class FlatOntologyManager(object) is a singleton.
OntologyUtils.py - paths and rules for ontology¶
Copyright CUED Dialogue Systems Group 2015 - 2017
Warning
content partly hard-coded (paths, dicts, etc.)
-
ontology.OntologyUtils.
get_database_path
(domainString)¶ Required function just to handle repository root location varying if running on grid machines etc
-
ontology.OntologyUtils.
get_domains_group
(domains)¶ domains has (needs to have) been checked to be in [‘camtourist’,’sftourist’,’electronics’,’all’]:
-
ontology.OntologyUtils.
get_ontology_path
(domainString)¶ Required function just to handle repository root location varying if running on grid machines etc :rtype: object