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

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

public class SemanticContentSearch
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
SemanticContentSearch()
          create an instance of the service.
SemanticContentSearch(boolean load)
           
 
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 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 getNumberOfResults(java.lang.String[] keywords, SearchConf conf)
          return the number of results mathcing the search parameters
 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
 SemanticContentResult[] getSemanticContentByKeywords(java.lang.String[] keywords, SearchConf conf)
          returns a list of semantic content results matching the parameters of the search
 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
 SemanticContentResult[] getSemanticContentWithBestCoverage(java.lang.String[] keywords, SearchConf conf)
          Semantic document search function that returns documents that not necessaraly match all the keywords.
 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
static void main(java.lang.String[] args)
           
 void submitURI(java.lang.String uri)
          Submit a URI to the crawler of Watson.
 
Methods inherited from class uk.ac.open.kmi.watson.services.WatsonService
getLiteralIndexSearcher, setDocumentIndexSearcher, setEntityIndexSearcher, setRelationIndexSearcher
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SemanticContentSearch

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


SemanticContentSearch

public SemanticContentSearch(boolean load)
Method Detail

getSemanticContentByKeywords

public SemanticContentResult[] getSemanticContentByKeywords(java.lang.String[] keywords,
                                                            SearchConf conf)
returns a list of semantic content results matching the parameters of the search

Parameters:
keywords - set of keywords to match
conf - configuration object to restrict the search
Returns:
a list of semantic content results

getNumberOfResults

public int getNumberOfResults(java.lang.String[] keywords,
                              SearchConf conf)
return the number of results mathcing the search parameters


getSemanticContentWithBestCoverage

public SemanticContentResult[] getSemanticContentWithBestCoverage(java.lang.String[] keywords,
                                                                  SearchConf conf)
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: re-implement with new crawler function in kmi-web11...

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).

main

public static void main(java.lang.String[] args)