uk.ac.open.kmi.watson.services
Class OntologySearch

java.lang.Object
  extended by uk.ac.open.kmi.watson.services.WatsonService
      extended by uk.ac.open.kmi.watson.services.OntologySearch

public class OntologySearch
extends WatsonService

Service for searching and inspecting semantic documents.

Author:
lg3388, md99

Field Summary
 
Fields inherited from class uk.ac.open.kmi.watson.services.WatsonService
CLASS, COMMENT, EXACT_MATCH, INDIVIDUAL, LABEL, LITERAL, LOCAL_NAME, NS, PROPERTY, TOKEN_MATCH
 
Constructor Summary
OntologySearch()
          create an instance of the service.
 
Method Summary
 java.lang.String executeSPARQLQuery(java.lang.String ontoURI, java.lang.String queryString)
          Executes and returns the results (a XML String) of a SPARQL query on the given semantic document.
 int getAverageRating(java.lang.String ontoURI)
          Returns the average rating of this ontology in Revyu.com
 java.lang.String[] getBestCoverageWithRestrictions(java.lang.String[] keywords, int scopeModifier, int entityTypeModifier, int matchTechnique)
          Semantic document search function that returns documents that not necessaraly match all the keywords.
 java.lang.String getCacheLocation(java.lang.String ontoURI)
          return the location of the cached file
 java.lang.String[] getComments(java.lang.String ontoURI)
          Returns the comments of the ontology element defined in this documents, if specified.
 java.lang.String getDLExpressivness(java.lang.String ontoURI)
          Returns the DL Expressivness of the ontology
 java.lang.String[] getImportedBy(java.lang.String ontoUri)
          Returns the set of URIs of the semantic document importing ontoURI
 java.lang.String[] getImports(java.lang.String ontoUri)
          Returns the set of URIs of the imported semantic document
 java.lang.String[] getLabels(java.lang.String ontoURI)
          Returns the labels of the ontology element defined in this documents, if specified.
 int getNumberOfReviews(java.lang.String ontoURI)
          Returns the number of reviews entered about this ontology in Revyu.com
 long getNumberOfStatement(java.lang.String ontoUri)
          Returns the size in Bytes of the ontology file
 java.lang.String getOMVFileLocation(java.lang.String ontoURI)
          Returns the location of the OMV file describing the semantic document
 java.lang.String getRevyuURL(java.lang.String ontoURI)
          Returns the URL of the considered ontology on Revyu.com
 java.lang.String[] getSemanticContentByKeywords(java.lang.String[] keywords)
          Default search method: search in any entity, any scope, using EXACT_MATCH matcher
 java.lang.String[] getSemanticContentByKeywordsWithRestrictions(java.lang.String[] keywords, int scopeModifier, int entityTypeModifier, int matchTechnique)
          Main semantic document search function.
 java.lang.String[] getSemanticContentByKeywordsWithRestrictionsPaginated(java.lang.String[] keywords, int scopeModifier, int entityTypeModifier, int matchTechnique, int start, int inc)
          Same as getSemanticContentByKeywordsWithRestrictions, but returns only a part of the results, specified by the start and inc parameters.
 java.lang.String[] getSemanticContentLanguages(java.lang.String ontoURI)
          Returns the set of languages employed by the semantic document
 java.lang.String[] getSemanticContentLocation(java.lang.String ontoURI)
          Returns the set of URLs of the given semantic document
 long getSizeInBytes(java.lang.String ontoURI)
          Returns the size in Bytes of the ontology file
 java.lang.String[] listClasses(java.lang.String ontoURI)
          Returns the list of class URIs of the given ontology
 java.lang.String[] listIndividuals(java.lang.String ontoURI)
          Returns the list of individual URIs of the given semantic document
 java.lang.String[] listProperties(java.lang.String ontoURI)
          Returns the list of property URIs of the given ontology
 java.lang.String[] listSemanticContents(int start, int stop)
          This function returns a list of URI corresponding to all the documents collected by Watson
 void submitURI(java.lang.String uri)
          Submit a URI to the crawler of Watson.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OntologySearch

public OntologySearch()
create an instance of the service. *

Method Detail

getSemanticContentByKeywords

public java.lang.String[] getSemanticContentByKeywords(java.lang.String[] keywords)
Default search method: search in any entity, any scope, using EXACT_MATCH matcher


getSemanticContentByKeywordsWithRestrictions

public java.lang.String[] getSemanticContentByKeywordsWithRestrictions(java.lang.String[] keywords,
                                                                       int scopeModifier,
                                                                       int entityTypeModifier,
                                                                       int matchTechnique)
Main semantic document search function. Returns semantic documents containing the given keywords, in the entities given by the entity modifier (classes, properties or individuals), more precisely in some particualar part of the entities specified by the scope modifier (NS, LOCAL_NAME, etc.), using the specified matcher (Exact or partial match)

Parameters:
keywords - the list of keywords to search
scopeModifier - where to search in entity, e.g. WatsonService.LOCAL_NAME+WatsonService.LABEL
entityTypeModifier - in which entity to search, e.g. WatsonService.CLASS+WatsonService.INDIVIDUAL
matchTechnique - the match technique, e.g. WatsonService.EXACT_MATCH
Returns:
a set of valid ontology indentifiers

getSemanticContentByKeywordsWithRestrictionsPaginated

public java.lang.String[] getSemanticContentByKeywordsWithRestrictionsPaginated(java.lang.String[] keywords,
                                                                                int scopeModifier,
                                                                                int entityTypeModifier,
                                                                                int matchTechnique,
                                                                                int start,
                                                                                int inc)
Same as getSemanticContentByKeywordsWithRestrictions, but returns only a part of the results, specified by the start and inc parameters.

Parameters:
keywords - the list of keywords to search
scopeModifier - where to search in entity, e.g. WatsonService.LOCAL_NAME+WatsonService.LABEL
entityTypeModifier - in which entity to search, e.g. WatsonService.CLASS+WatsonService.INDIVIDUAL
matchTechnique - the match technique, e.g. WatsonService.EXACT_MATCH
start - the indice of the first element to be return in the total set of results
inc - the number of results to return
Returns:
a set of valid ontology indentifiers

getBestCoverageWithRestrictions

public java.lang.String[] getBestCoverageWithRestrictions(java.lang.String[] keywords,
                                                          int scopeModifier,
                                                          int entityTypeModifier,
                                                          int matchTechnique)
Semantic document search function that returns documents that not necessaraly match all the keywords. Calculate the set of documents that best cover the set of keywords (match a maximal subset of the keywords. This function is relatively fast for less than 10 keywords, but can takes very long (several days!) above that treshold.

Parameters:
keywords - the list of keywords to search
scopeModifier - where to search in entity, e.g. WatsonService.LOCAL_NAME+WatsonService.LABEL
entityTypeModifier - in which entity to search, e.g. WatsonService.CLASS+WatsonService.INDIVIDUAL
matchTechnique - the match technique, e.g. WatsonService.EXACT_MATCH
Returns:
a set of valid ontology indentifiers

listSemanticContents

public java.lang.String[] listSemanticContents(int start,
                                               int stop)
This function returns a list of URI corresponding to all the documents collected by Watson

Parameters:
start - the number of the first document to retrieve
stop - the number of the last document to retrieve
Returns:
a list of URI of semantic content (semantic document, ontologies) of start-stop if stop is smaller than the total number of documents.

getSemanticContentLocation

public java.lang.String[] getSemanticContentLocation(java.lang.String ontoURI)
Returns the set of URLs of the given semantic document

Parameters:
ontoURI - the URI identifying the considered semantic document
Returns:
a set of URLs where the ontology can be found

getCacheLocation

public java.lang.String getCacheLocation(java.lang.String ontoURI)
return the location of the cached file

Parameters:
ontoURI - the URI identifying the considered ontology
Returns:
the URLs where the ontology can be found in the Watson cache

getSizeInBytes

public long getSizeInBytes(java.lang.String ontoURI)
Returns the size in Bytes of the ontology file

Parameters:
ontoURI - the URI identifying the considered ontology
Returns:
the size in bytes of the file

getSemanticContentLanguages

public java.lang.String[] getSemanticContentLanguages(java.lang.String ontoURI)
Returns the set of languages employed by the semantic document

Parameters:
ontoURI - the URI identifying the considered semantic document
Returns:
a set of String corresponding to the employed langauges

getDLExpressivness

public java.lang.String getDLExpressivness(java.lang.String ontoURI)
Returns the DL Expressivness of the ontology

Parameters:
ontoURI - the URI identifying the considered ontology
Returns:
a String for Dl expressivmess

listClasses

public java.lang.String[] listClasses(java.lang.String ontoURI)
Returns the list of class URIs of the given ontology

Parameters:
ontoURI - the identificator of the considered ontology
Returns:
a set of class URIs from ontoURI

listProperties

public java.lang.String[] listProperties(java.lang.String ontoURI)
Returns the list of property URIs of the given ontology

Parameters:
ontoURI - the identificator of the considered ontology
Returns:
a set of property URIs from ontoURI

listIndividuals

public java.lang.String[] listIndividuals(java.lang.String ontoURI)
Returns the list of individual URIs of the given semantic document

Parameters:
ontoURI - the identificator of the considered ontology
Returns:
a set of individual URIs from ontoURI

getImports

public java.lang.String[] getImports(java.lang.String ontoUri)
Returns the set of URIs of the imported semantic document

Parameters:
ontoURI - the URI identifying the considered semantic document
Returns:
a set of URIs of imported semantic documents

getImportedBy

public java.lang.String[] getImportedBy(java.lang.String ontoUri)
Returns the set of URIs of the semantic document importing ontoURI

Parameters:
ontoURI - the URI identifying the considered semantic document
Returns:
a set of URIs of semantic documents importing ontoURI

getNumberOfStatement

public long getNumberOfStatement(java.lang.String ontoUri)
Returns the size in Bytes of the ontology file

Parameters:
ontoURI - the URI identifying the considered ontology
Returns:
the size in bytes of the file

executeSPARQLQuery

public java.lang.String executeSPARQLQuery(java.lang.String ontoURI,
                                           java.lang.String queryString)
Executes and returns the results (a XML String) of a SPARQL query on the given semantic document.

Parameters:
ontoURI - the URI of the semantic document on which we want the query to be executed
queryString - the string containing the SPARQL query
Returns:
the XML serialization of the result

getNumberOfReviews

public int getNumberOfReviews(java.lang.String ontoURI)
Returns the number of reviews entered about this ontology in Revyu.com

Parameters:
ontoURI - the URI of the considered ontology

getAverageRating

public int getAverageRating(java.lang.String ontoURI)
Returns the average rating of this ontology in Revyu.com

Parameters:
ontoURI - the URI of the considered ontology
Returns:
the rounded average rating from revyu [1-5], or 0 if no reviews

getRevyuURL

public java.lang.String getRevyuURL(java.lang.String ontoURI)
Returns the URL of the considered ontology on Revyu.com

Parameters:
ontoURI - the URI of the considered ontology
Returns:
the URL of the considered ontology on revyu.com, or null if it does not exist

getOMVFileLocation

public java.lang.String getOMVFileLocation(java.lang.String ontoURI)
Returns the location of the OMV file describing the semantic document

Parameters:
the - URI of the considered ontology

submitURI

public void submitURI(java.lang.String uri)
Submit a URI to the crawler of Watson. TODO: needs testing!!! TODO: do it with direct access to the crawler DB...

Parameters:
uri - the URI to be crawled by Watson.

getLabels

public java.lang.String[] getLabels(java.lang.String ontoURI)
Returns the labels of the ontology element defined in this documents, if specified.

Parameters:
ontoURI - the URI of the ontology to consider
Returns:
a set of labels for the ontology or an empty array (or null if error).

getComments

public java.lang.String[] getComments(java.lang.String ontoURI)
Returns the comments of the ontology element defined in this documents, if specified.

Parameters:
ontoURI - the URI of the ontology to consider
Returns:
a set of comments for the ontology or an empty array (or null if error).