public void runTranslator() throws Exception { // language ontology String langOnt = "http://www.daml.org/2003/09/factbook/languages#"; OWLKnowledgeBase kb = OWLFactory.createKB(); // we at least need RDFS reasoning to evaluate preconditions (to understand // that process:Parameter is subclass of swrl:Variable) kb.setReasoner("RDFS"); service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/BabelFishTranslator.owl"); process = service.getProcess(); // get the references for these values OWLIndividual English = kb.getIndividual(URI.create(langOnt + "English")); OWLIndividual French = kb.getIndividual(URI.create(langOnt + "French")); // initialize the input values to be empty values = new ValueMap(); values.setDataValue(process.getInput("InputString"), "Hello world!"); values.setValue(process.getInput("InputLanguage"), English); values.setValue(process.getInput("OutputLanguage"), French); values = exec.execute(process, values); // get the output using local name outValue = values.getValue(process.getOutput()).toString(); // display the results System.out.println("Executed service '" + service + "'"); System.out.println( "Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL()); System.out.println("Output = " + outValue); System.out.println(); }
public void runFindCheaperBook() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); // we need a reasoner for example to work kb.setReasoner("Pellet"); // we need to check preconditions so that local variables will be assigned values exec.setPreconditionCheck(true); // read the service description service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/FindCheaperBook.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); // use an arbitrary book name values.setDataValue(process.getInput("BookName"), "City of Glass"); values = exec.execute(process, values); // get the output values OWLIndividual price = values.getIndividualValue(process.getOutput("BookPrice")); String bookstore = values.getStringValue(process.getOutput("Bookstore")); // display the results System.out.println("Executed service " + service); System.out.println("Bookstore = " + bookstore); System.out.println("Price = "); System.out.println(Utils.formatRDF(price.toRDF())); System.out.println(); }
public void run() throws Exception { // register a converter for Owner class OWLObjectConverterRegistry.instance() .registerConverter(OwnerEntity.class, new OwnerConverter()); // Override the default Profile converter to return ExtendedProfile descriptions OWLObjectConverterRegistry.instance() .registerConverter(Profile.class, new ExtendedProfileConverter()); // Create a KB final OWLKnowledgeBase kb = OWLFactory.createKB(); // use a reasoner that will understand class and property inheritance kb.setReasoner("Pellet"); // Load an example service description final Service s = kb.readService(ExampleURIs.DICTIONARY_OWLS12); // Cast the profile to an ExtendedProfile (since default converter is overridden) final ExtendedProfile profile = s.getProfile().castTo(ExtendedProfile.class); // Get the owner info final OwnerEntity owner = profile.getOwner(); // Print the results System.out.println("Service name: " + profile.getServiceName()); System.out.println(); System.out.println("Display service parameters using generic functions"); System.out.println("--------------------------------------------------"); final OWLIndividualList<ServiceParameter> params = profile.getServiceParameters(); for (ServiceParameter param : params) { System.out.println("Service Parameter: "); System.out.println(" Name : " + param.getName()); System.out.println(" Value : " + param.getParameter()); } System.out.println(); System.out.println("Display service parameters using custom functions"); System.out.println("-------------------------------------------------"); System.out.println("Owner: "); System.out.println(" Name : " + owner.getLabel(null)); System.out.println(" ID : " + owner.getEntityID()); }
public void runFrenchDictionary() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); // we need a reasoner that can evaluate the precondition of the translator kb.setReasoner("Pellet"); service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/FrenchDictionary.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); inValue = "mere"; values.setDataValue(process.getInput("InputString"), inValue); values = exec.execute(process, values); // get the output using local name outValue = values.getValue(process.getOutputs().getParameter("OutputString")).toString(); // display the results System.out.println("Executed service " + service); System.out.println("Input = " + inValue); System.out.println("Output = " + outValue); System.out.println(); }