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 runBookPrice() throws Exception {
    String currencyOnt = "http://www.daml.ecs.soton.ac.uk/ont/currency.owl#";

    OWLKnowledgeBase kb = OWLFactory.createKB();

    // read the service description
    service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/BookPrice.owl");
    process = service.getProcess();

    // initialize the input values to be empty
    values = new ValueMap();

    // use an arbitrary book name
    inValue = "City of Glass";
    // get the parameter using the local name
    values.setDataValue(process.getInput("BookName"), inValue);
    values.setValue(
        process.getInput("Currency"), kb.getIndividual(URI.create(currencyOnt + "EUR")));
    values = exec.execute(process, values);

    // get the output param using the index
    OWLIndividual out = values.getIndividualValue(process.getOutput());

    // display the results
    System.out.println("Executed service " + service);
    System.out.println("Book Name = " + inValue);
    System.out.println("Price = ");
    System.out.println(Utils.formatRDF(out.toRDF()));
    System.out.println();
  }
Exemple #3
0
  public OWLIndividual convertJenaToOWLIndividual(JenaIndividual ind) {
    URI uri = GetURLContents.getURI(ind.getURI());
    try {
      kb.read(uri);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return kb.getIndividual(uri);
  }
  public void runCurrencyConverter() throws Exception {
    String currencyOnt = "http://www.daml.ecs.soton.ac.uk/ont/currency.owl#";
    String conceptsOnt = "http://www.mindswap.org/2004/owl-s/concepts.owl#";

    OWLKnowledgeBase kb = OWLFactory.createKB();
    // read the service description
    service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/CurrencyConverter.owl");
    process = service.getProcess();

    // initialize the input values to be empty
    values = new ValueMap();

    OWLIndividual EUR = kb.getIndividual(URI.create(currencyOnt + "EUR"));
    values.setValue(process.getInput("OutputCurrency"), EUR);

    OWLIndividual USD = kb.getIndividual(URI.create(currencyOnt + "USD"));

    OWLClass Price = kb.getClass(URI.create(conceptsOnt + "Price"));
    OWLObjectProperty currency = kb.getObjectProperty(URI.create(conceptsOnt + "currency"));
    OWLDataProperty amount = kb.getDataProperty(URI.create(conceptsOnt + "amount"));

    OWLIndividual inputPrice = kb.createInstance(Price);
    inputPrice.addProperty(currency, USD);
    inputPrice.addProperty(amount, "100");

    // get the parameter using the local name
    values.setValue(process.getInput("InputPrice"), inputPrice);

    values = exec.execute(process, values);

    // get the output param using the index
    OWLIndividual out = values.getIndividualValue(process.getOutput());

    // display the results
    System.out.println("Executed service " + service);
    System.out.println(
        "Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL());
    System.out.println("Input  = ");
    System.out.println(Utils.formatRDF(inputPrice.toRDF()));
    System.out.println("Output = ");
    System.out.println(Utils.formatRDF(out.toRDF()));
    System.out.println();
  }
Exemple #5
0
 public OWLIndividual getOWLIndividual(String uri) {
   URI uriObject = GetURLContents.getURI(uri);
   return kb.getIndividual(uriObject);
 }