Package: virtual-assistant-generator
Virtual Assistant extensions GeneratorIt provides a Generator of Virtual Assistant extensions to reply Natural Language (NL) questions by querying SPARQL endpoints.
In its actual version (v. 1.0), our generator enables the generation of Alexa skills.
The implemented mechanism to move from NL to SPARQL queries is KG-independent. Thus, it can be applied to any SPARQL endpoint that enables GET requests and returns JSON results.
It simplifies the skill generation both for technical and lay-users.
The effort is strictly related to the provision of queriable entities and predicates, while the generation of the Alexa skill is as simple as the call of a command.The generator is maintained by theISISLabof the University of Salerno.Generator structure and extension pointsOur generator can create a VA extension according to the configuration file provided by the user. It takes as input a conf.json file, checks its syntax correctness and semantic validity and, finally, creates the VA extension. Each phase is kept separate by satisfying the modularity requirement, and it is implemented as an abstract module. The architecture of our general-purpose and multi speaking languages VA extension generator is reported in the figure below.TheVocal Assistant Generatormodule takes as input a configuration file to personalize the generated VA extension and conducts the entire generation workflow, i.e., it 1) checks the syntactical correctness of the configuration file by theSyntax checker; 2) validates the semantic correctness of the configuration by theValidator; 3) creates the interaction_model.json by theInteraction Model Generatorcontaining configured intents, its utterances and the slot values personalized by the user; iv) generates the back-end code by theBack-end generatorand it produces the zip file containing the intent implementation.While the syntax checker and the validator strictly depend on the configuration file, the interaction model and the back-end generator depend on the API provided by the VA to extend its features. We require a JSON configuration file. Therefore, theJSON Syntax Checkerhas to verify that the file is a valid JSON file, while theValidatorchecks if all the mandatory fields are provided, and the configuration is consistent, e.g., we verify that entities and properties are provided if there is at least one intent that uses them as a slot.
Once validated the configuration file, the Alexa skills components (the JSON interaction model and the zip file implementing the skill back-end that can be upload on Amazon AWS) can be created. Thanks to the architecture modularity, it is easy to develop new VA providers support and extend the supported languages (English and Italian at the moment).Due to the modularity of the implementation, the extensions point are:the supported languages (by affecting the instance of Interaction Model Generator and by providing the interaction model components according to the desired language);the Vocal Assistant (by providing a dedicated implementation of the Abstract Interaction Model and Abstract Back-end).Repository structuresrccontainspa_generator.pycontaining both the Abstract PersonalAssistantGenerator and the Alexa implementation,syntax_checker.pycontaining both the AbstractSyntaxChecker and the JSONSyntaxChecker,validator.pycontaining both the AbstracValidator and the actual Validator,interaction_model_generator.pycontaining both the InteractionModel abstract class and the AlexaInteractionModel,en_interaction_model_components.jsonandit_interaction_model_components.pycontaining the interaction model components for the English and the Italian languages,back_end_generator.pycontaining both the Abstract BackEndGenerator and the Alexa instance. It exploits the content of the back_end folder,back_endfolder, containingindex.jscontains the back_end code in JavaScript;custom_functions.jscontains the functions that the user may need to modify to personalize the entities and properties look-up (for instance, by exploiting API instead on pre-defined dictionaries),package-lock.jsonandpackage.jsonto manage Node.js packages,node_modulesfolder, containing all the required Node.js packages,conf.jsonan exemplerary configuration file,main.pythat starts the VA extension generation according to the configuration file.use casescontainsthe configuration file and the Alexa skill components (interaction model and back end) for DBpedia and Wikidata and general-purpose Knowledge Graphs (KGs), the UNESCO Thesaurus, the WarSampo and WordNet as special-purpose KGs.
Each skill is provided in an individual folder.the evaluation of the Wikidata and DBpedia Alexa skills against QLAD-7 and QALD-9 (respectively). We report the used datasets, the skill replies, the code used to compare gold standard and actual results, and the achieved results.SPARQL_endpoint_analysiscontainsanalysis_queries.mdthe used SPARQL queries to retrieve classes, properties and resources from KGs,conf_generator.mdthe code to estimate the SPARQL endpoint readiness in being queried by Vocal Assistants. In calculating the VA_readiness_score, we took into account the coverage of labels, the readability of labels and the uniqueness of URLs attached to the same label,conf_generator_and_va_readiness_score.ipynbprovides a Jupyter Notebbok to test conf_generator.py on the UNESCO Thesaurus KG,analysis_results.mdcontains the VA_readiness of 30 available SPARQL endpoints.Generator detailsSupported intentsThe implemented intents, an example of provided utterance and the queried triples can be summarized as follows:Intent nameUtteranceTriplegetPropertyObjectWhat is the {p} of {e}?<e> <p> ?getDescriptionWhat/Who is {e}?<e> <definition> ?getLocationWhere is {e}?<e> <location> ?getImgShow me <e><e> <img> ?getPropertyObjectByClassWhich {c} is the {p} of {e}?<e> <p> ?. ? <instanceof> <c>getPropertySubjectWhat has {e} as {p}?? <p> <e>getClassInstancesWhat are the instances of {e}?? <instanceof> <e>getPropertySubjectByClassWhich {c} has {e} as {p}?? <instanceof> <c>.<br>? <p> <e>.getNumericFilterWhat has {p} {symbol} {val}?? <p> ?o. <br> FILTER(?o <symbol> <val>)getNumeriFilterByClassWhich {c} has {p} {symbol} {val}?? <instanceof> <c>.? <p> ?o. <br> FILTER(?o <symbol> <val>)getSuperlativeWhat is the {c} with {sup} {p}?? <p> ?o.<br> ORDER BY (?o).<br> LIMIT 1getTripleVerification{s} has {o} as {p}ASK 
 <p> <o>getAllResultsPreviousQueryGive me all the results-Configuration file formatIn its actual implementation, we require a JSON file with the following format:{
"invocation_name" : INVOCATION NAME,
"endpoint" : SPARQL endpoint,
"intents" : LIST OF THE DESIRED INTENTS,
"lang" : EN|IT,
"entities" : {...},
"properties" : {...}
}Entities and properties are modelled as dictionaries with the following format:LABEL : {
"urls" : LIST OF URLs [,
"synonyms" : LIST OF SYNONYMS]
}Running detailsTo generate the Alexa skill, you have:provide the configuration file (e.g., conf.json),create an instance of the generator (i.e., AlexaSkillGenerator()),call the generate_personal_assistant function on the generator by providing the configuration file (e.g., generator.generate_personal_assistant("conf.json")).Results storageThe Alexa skill will be stored on the local path. The generator will create:a folder named as the <INVOCATION_NAME> provided in the configuration file, containinggenerated_interaction_model.json that is the interaction model as expected by theAlexa Developer Consolea back_end.zip file containing the back end (implemented in JavaScript) that can be directly uploaded onAmazon AWS.DependenciesThe generator is implemented in Python 3.0LicenseThe code is Open-Source the MIT License applies to the provided source code.Permanent URIA permanent version of this repository is provided onZenodo.