Class WebIsAlodSPARQLservice
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.webIsAlod.WebIsAlodSPARQLservice
This class performs SPARQL queries for the WebIsALOD data set.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration of the two available endpoints. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
private ConcurrentMap<String,
Set<String>> Hypernym Buffer (for isa queries)private ConcurrentMap<StringString,
Boolean> Hypernymy Buffer (for ask queries)private static HashMap<String,
WebIsAlodSPARQLservice> Singleton instances per endpoint.private boolean
If the disk-buffer is disabled, no buffers are read/written from/to the disk.private boolean
True if a tdb source shall be used rather than an on-line SPARQL endpoint.private ConcurrentMap<String,
String> Label2URI buffer (linking buffer)private static final org.slf4j.Logger
Default loggerprivate PersistenceService
Service responsible for disk buffers.private ConcurrentMap<StringString,
Boolean> Synonymy Bufferprivate org.apache.jena.query.Dataset
The TDB dataset into which the DBpedia data set was loaded.private org.apache.jena.rdf.model.Model
TDB modelInstance Endpoint.private static final String
-
Constructor Summary
ModifierConstructorDescriptionprivate
WebIsAlodSPARQLservice
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlEndpoint, boolean isDiskBufferEnabled) Private Constructor (singleton pattern).private
WebIsAlodSPARQLservice
(String tdbDirectoryPath, boolean isDiskBufferEnabled) Private TDB constructor (singleton pattern). -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Clean-up and close db.static void
void
commit
(PersistenceService.PreconfiguredPersistences persistences) getHypernyms
(String uri, double confidence) Obtain isa concepts for the given uri.static WebIsAlodSPARQLservice
getInstance
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint) Singleton Pattern to get Sparql service instance.static WebIsAlodSPARQLservice
getInstance
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, boolean isDiskBufferEnabled) Singleton Pattern to get Sparql service instance.static WebIsAlodSPARQLservice
getInstance
(String tdbDirectoryPath) Singleton to get TDB-based SPARQL instance.static WebIsAlodSPARQLservice
getInstance
(String tdbDirectoryPath, boolean isDiskBufferEnabled) Singleton to get TDB-based SPARQL instance.private static String
getIsHypernymousAskQueryClassic
(String uri1, String uri2, double minimumConfidence, boolean isClassic) Obtain a query to check for hypernymy.private static String
getIsSynonymousAskQueryClassic
(String uri1, String uri2) Returns an ASK query that can be used to derive synonymy from the WebIsALOD data set.private static String
getIsSynonymousAskQueryClassic
(String uri1, String uri2, double minimumConfidence, boolean isClassic) Obtain a query to check for synonymy.getUriUsingLabel
(WebIsAlodSPARQLservice.WebIsAlodEndpoint webIsAlodEndpoint, String label) Returns the URI to a given label under the premises that the label can be linked to a resource.getUriUsingLabel
(String label) Returns the URI to a given label under the premises that the label can be linked to a resource.boolean
hasBroaderConcepts
(String uri) Determines whether a concept has a hypernym.private void
Initializes local database.static boolean
Checks whether the URI in question is a concept of the ALOD XL webIsAlodEndpoint.boolean
isConceptOnDataSet
(String uri) Checks whether the concept behind the given URI is available on WebIsALOD.boolean
private boolean
isHypernymous
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2, double minimumConfidence) Internal method that can execute a hypernymy ask query with a given minimum confidence threshold.boolean
isHypernymous
(String uri1, String uri2) Assumed minimum confidence: 0.0.boolean
isHypernymous
(String uri1, String uri2, double minimumConfidence) private boolean
isSynonymous
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2) Internal method that can execute a synonymy ask query without minimum confidence threshold.private boolean
isSynonymous
(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2, double minimumConfidence) Internal method that can execute a synonymy ask query with a given minimum confidence threshold.boolean
isSynonymous
(String uri1, String uri2) Checks whether the two URIs are synonymous.boolean
isSynonymous
(String uri1, String uri2, double minimumConfidence) Checks whether the two URIs are synonymous.boolean
isURIinDictionary
(String uri) Checks whether there is a resource with the given URI available at the given endpoint.void
setDiskBufferEnabled
(boolean diskBufferEnabled) Note that when you disable your buffer during runtime, the buffer will be reinitialized.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERDefault logger -
synonymyAskBuffer
Synonymy Buffer -
hypernymyAskBuffer
Hypernymy Buffer (for ask queries) -
hypernymBuffer
Hypernym Buffer (for isa queries) -
labelUriBuffer
Label2URI buffer (linking buffer) -
isDiskBufferEnabled
private boolean isDiskBufferEnabledIf the disk-buffer is disabled, no buffers are read/written from/to the disk. Default: true. -
persistenceService
Service responsible for disk buffers. -
webIsAlodEndpoint
Instance Endpoint. -
instances
Singleton instances per endpoint. -
CLASSIC_CONFIDENCE
- See Also:
-
XL_CONFIDENCE
- See Also:
-
isUseTdb
private boolean isUseTdbTrue if a tdb source shall be used rather than an on-line SPARQL endpoint. -
tdbDataset
private org.apache.jena.query.Dataset tdbDatasetThe TDB dataset into which the DBpedia data set was loaded. -
tdbModel
private org.apache.jena.rdf.model.Model tdbModelTDB model
-
-
Constructor Details
-
WebIsAlodSPARQLservice
private WebIsAlodSPARQLservice(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlEndpoint, boolean isDiskBufferEnabled) Private Constructor (singleton pattern).- Parameters:
sparqlEndpoint
- The SPARQL endpoint URI.isDiskBufferEnabled
- True if disk buffer is enabled.
-
WebIsAlodSPARQLservice
Private TDB constructor (singleton pattern).- Parameters:
tdbDirectoryPath
- Path to the TDB 1 directory.isDiskBufferEnabled
- True if buffer enabled, else false.
-
-
Method Details
-
getInstance
public static WebIsAlodSPARQLservice getInstance(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint) Singleton Pattern to get Sparql service instance.- Parameters:
sparqlWebIsAlodEndpoint
- Desired webIsAlodEndpoint.- Returns:
- Instance.
-
getInstance
Singleton to get TDB-based SPARQL instance.- Parameters:
tdbDirectoryPath
- The path to the TDB directory.- Returns:
- Instance
-
getInstance
public static WebIsAlodSPARQLservice getInstance(String tdbDirectoryPath, boolean isDiskBufferEnabled) Singleton to get TDB-based SPARQL instance.- Parameters:
tdbDirectoryPath
- The path to the TDB directory.isDiskBufferEnabled
- True if disk buffer shall be enabled.- Returns:
- Instance.
-
getInstance
public static WebIsAlodSPARQLservice getInstance(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, boolean isDiskBufferEnabled) Singleton Pattern to get Sparql service instance.- Parameters:
sparqlWebIsAlodEndpoint
- Desired webIsAlodEndpoint.isDiskBufferEnabled
- Indicator whether the disk buffer shall be used.- Returns:
- Instance.
-
initializeBuffers
private void initializeBuffers()Initializes local database. -
isConceptOnDataSet
Checks whether the concept behind the given URI is available on WebIsALOD. Availability is defined as "has at least one broader concept".- Parameters:
uri
- The URI that shall be looked up.- Returns:
- True if found, else false.
-
hasBroaderConcepts
Determines whether a concept has a hypernym.- Parameters:
uri
- the URI for which hypernymy has to be checked.- Returns:
- True if a hypernym exists, else false.
-
isSynonymous
Checks whether the two URIs are synonymous. If one or both URIs cannot be found in the data set, the default answer is false.- Parameters:
uri1
- URI as String.uri2
- URI as String.- Returns:
- True if synonymous according to ALOD, else false.
-
isSynonymous
Checks whether the two URIs are synonymous. If one or both URIs cannot be found in the data set, the default answer is false.- Parameters:
uri1
- URI as String.uri2
- URI as String.minimumConfidence
- The required minimum confidence.- Returns:
- True if synonymous according to ALOD, else false.
-
isHypernymous
-
isHypernymous
Assumed minimum confidence: 0.0.- Parameters:
uri1
- URI 1uri2
- URI 2- Returns:
- True if hypernymy relation exists.
-
isSynonymous
private boolean isSynonymous(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2, double minimumConfidence) Internal method that can execute a synonymy ask query with a given minimum confidence threshold.- Parameters:
sparqlWebIsAlodEndpoint
- SPARQL endpoint.uri1
- URI as String.uri2
- URI as String.minimumConfidence
- Minimum confidence- Returns:
- True if synonymous according to ALOD, else false.
-
getHypernyms
Obtain isa concepts for the given uri.- Parameters:
uri
- The URI for which hypernyms shall be found.confidence
- Minimum confidence.- Returns:
- A set of hypernyms.
-
isSynonymous
private boolean isSynonymous(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2) Internal method that can execute a synonymy ask query without minimum confidence threshold.- Parameters:
sparqlWebIsAlodEndpoint
- SPARQL endpoint.uri1
- URI as String.uri2
- URI as String.- Returns:
- True if synonymous according to ALOD, else false.
-
getIsSynonymousAskQueryClassic
Returns an ASK query that can be used to derive synonymy from the WebIsALOD data set.- Parameters:
uri1
- URI 1 as String.uri2
- URI 2 as String.- Returns:
- The query in String representation.
-
isHypernymous
private boolean isHypernymous(WebIsAlodSPARQLservice.WebIsAlodEndpoint sparqlWebIsAlodEndpoint, String uri1, String uri2, double minimumConfidence) Internal method that can execute a hypernymy ask query with a given minimum confidence threshold.- Parameters:
sparqlWebIsAlodEndpoint
- SPARQL endpoint.uri1
- URI as String.uri2
- URI as String.minimumConfidence
- Minimum confidence- Returns:
- True if hypernymous according to ALOD, else false.
-
getIsSynonymousAskQueryClassic
private static String getIsSynonymousAskQueryClassic(String uri1, String uri2, double minimumConfidence, boolean isClassic) Obtain a query to check for synonymy.- Parameters:
uri1
- URI of concept 1.uri2
- URI of concept 2.minimumConfidence
- The required minimum confidence. Must be in the range [0, 1].isClassic
- Indicator whether the query is for the classic data set. False is interpreted as XL endpoint.- Returns:
- Query in String representation.
-
getIsHypernymousAskQueryClassic
private static String getIsHypernymousAskQueryClassic(String uri1, String uri2, double minimumConfidence, boolean isClassic) Obtain a query to check for hypernymy.- Parameters:
uri1
- URI of concept 1.uri2
- URI of concept 2.minimumConfidence
- The minimum confidence that shall apply.isClassic
- True if it is classic, else false.- Returns:
- Query in String format. False is interpreted as XL endpoint.
-
isALODxlEndpointConcept
Checks whether the URI in question is a concept of the ALOD XL webIsAlodEndpoint.- Parameters:
uri
- The URI which shall be checked.- Returns:
- true if URI is XL webIsAlodEndpoint concept.
-
getUriUsingLabel
Returns the URI to a given label under the premises that the label can be linked to a resource. lse null will be returned.- Parameters:
label
- The label that shall be used for the lookup.- Returns:
- null if not found, else URI as String.
-
getUriUsingLabel
public String getUriUsingLabel(WebIsAlodSPARQLservice.WebIsAlodEndpoint webIsAlodEndpoint, String label) Returns the URI to a given label under the premises that the label can be linked to a resource. Else null will be returned.- Parameters:
webIsAlodEndpoint
- The SPARQL webIsAlodEndpoint.label
- The label that shall be used for the lookup.- Returns:
- null if not found, else URI as String.
-
isURIinDictionary
Checks whether there is a resource with the given URI available at the given endpoint.- Parameters:
uri
- The URI to be looked for.- Returns:
- True if URI exists, else false.
-
commit
-
close
public void close()Clean-up and close db. This method will also shut down the WebIsAlodSPARQL service. -
closeAllServices
public static void closeAllServices() -
isDiskBufferEnabled
public boolean isDiskBufferEnabled() -
setDiskBufferEnabled
public void setDiskBufferEnabled(boolean diskBufferEnabled) Note that when you disable your buffer during runtime, the buffer will be reinitialized.- Parameters:
diskBufferEnabled
- True for enablement, else false.
-