Advertisement
Advertisement
| 05.22.2008 at 06:14AM PDT, ID: 23424233 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: |
// The MIT License
//
// Copyright (c) 2004 Evren Sirin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
/*
* Created on Mar 19, 2004
*/
import java.net.URI;
import org.mindswap.owl.OWLClass;
import org.mindswap.owl.OWLDataProperty;
import org.mindswap.owl.OWLDataValue;
import org.mindswap.owl.OWLFactory;
import org.mindswap.owl.OWLIndividual;
import org.mindswap.owl.OWLKnowledgeBase;
import org.mindswap.owl.OWLObjectProperty;
import org.mindswap.owls.OWLSFactory;
import org.mindswap.owls.process.Process;
import org.mindswap.owls.process.execution.DefaultProcessMonitor;
import org.mindswap.owls.process.execution.ProcessExecutionEngine;
import org.mindswap.owls.profile.Profile;
import org.mindswap.owls.service.Service;
import org.mindswap.query.ValueMap;
import org.mindswap.wsdl.WSDLOperation;
import org.mindswap.wsdl.WSDLService;
/**
*
* Examples to show how services can be executed. Some examples of simple execution monitoring is
* included.
*
* @author Evren Sirin
*/
public class RunService {
Service service;
Profile profile;
Process process;
WSDLService s;
WSDLOperation op;
String inValue;
String outValue;
ValueMap values;
ProcessExecutionEngine exec;
public RunService() {
// create an execution engine
exec = OWLSFactory.createExecutionEngine();
// Attach a listener to the execution engine
exec.addMonitor(new DefaultProcessMonitor());
}
public void runZipCode() throws Exception {
OWLKnowledgeBase kb = OWLFactory.createKB();
service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/ZipCodeFinder.owl");
process = service.getProcess();
// initialize the input values to be empty
values = new ValueMap();
values.setDataValue(process.getInput("City"), "College Park");
values.setDataValue(process.getInput("State"), "MD");
values = exec.execute(process, values);
// get the result
OWLIndividual out = values.getIndividualValue(process.getOutput());
// do something with output
}
public void runJGroundingTest() throws Exception {
OWLKnowledgeBase kb = OWLFactory.createKB();
// read the service description
service = kb.readService("http://www.ifi.unizh.ch/ddis/ont/owl-s/JGroundingTest.owl");
process = service.getProcess();
// get the parameter using the local name
values = new ValueMap();
values.setDataValue(process.getInput("FirstParam"), "2");
values.setDataValue(process.getInput("SecParam"), "3");
values = exec.execute(process, values);
// do something with output
}
public void runBookFinder() throws Exception {
OWLKnowledgeBase kb = OWLFactory.createKB();
// read the service description
service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl");
process = service.getProcess();
// initialize the input values to be empty
values = new ValueMap();
// use any book name
inValue = "City of Glass";
// get the parameter using the local name
values.setDataValue(process.getInput("BookName"), inValue);
values = exec.execute(process, values);
// get the output param using the index
OWLIndividual out = values.getIndividualValue(process.getOutput());
// do something with output
}
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());
// do something with output
}
public void runFindCheaperBook() throws Exception {
OWLKnowledgeBase kb = OWLFactory.createKB();
// 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"));
// do something with output
}
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());
// do something with output
}
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();
// do something with output
}
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();
// do something with output
}
public void runDictionary() throws Exception {
OWLKnowledgeBase kb = OWLFactory.createKB();
service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/Dictionary.owl");
process = service.getProcess();
// initialize the input values to be empty
values = new ValueMap();
inValue = "hello";
values.setDataValue(process.getInput("InputString"), inValue);
values = exec.execute(process, values);
// get the output
OWLDataValue out = (OWLDataValue) values.getValue(process.getOutput());
// do something with output
}
public void runAll() throws Exception {
try {
runCurrencyConverter();
} catch(Exception e) {
}
try {
runZipCode();
} catch(Exception e) {
}
try {
runTranslator();
} catch(Exception e) {
}
try {
runJGroundingTest();
} catch(Exception e) {
}
try {
runDictionary();
} catch(Exception e) {
}
try {
runBookFinder();
} catch(Exception e) {
}
try {
runFrenchDictionary();
} catch(Exception e) {
}
try {
runBookPrice();
} catch(Exception e) {
}
try {
runFindCheaperBook();
} catch(Exception e) {
}
}
public static void main(String[] args) throws Exception {
RunService test = new RunService();
test.runAll();
}
}
|