This system leverages CodeOntology to translate complex natural language questions into an appropriate Java source code.
For instance, the question:
What is the cube root of the max between 20 and 27?
is translated into the following Java source code:
java.lang.Math.cbrt(java.lang.Double.max(20, 27))
which is executed to retrieve the desired answer.
First, be sure that Fuseki is running at localhost:3030. If you don't have Fuseki installed, you can get it by following the instructions available here.
Next, you should download the dataset extracted by applying CodeOntology to the OpenJDK 8 project. It is available on Zenodo under CC BY 4.0 license.
Create a new dataset named OpenJDK
on Fuseki and load all the files you have downloaded from Zenodo to the newly created dataset.
Now, you should be able to use Fuseki to run simple queries on CodeOntology. For instance, you can select all methods from OpenJDK computing the cube root of a real value by running the following SPARQL query:
PREFIX woc: <http://rdf.webofcode.org/woc/>
PREFIX dul: <http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT ?method
WHERE {
?method a woc:Method ;
woc:hasParameter/woc:hasType woc:Double ;
dul:associatedWith dbr:Cube_root .
}
This system makes use of a pre-trained Word2Vec model. You can download it from Google Drive or simply run the following script, which will place the file in nlp/WordVectors
:
$ ./getW2V.sh
The system is built with Maven. Be sure to use OpenJDK 8 (incompatibility with JDK 10 is known). Hence, you only have to run the following commands:
$ cd QuestionAnswering
$ mvn package
Now, you are ready to run the tool:
$ ../askCO