java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.webIsAlod.WebIsAlodSPARQLservice

public class WebIsAlodSPARQLservice extends Object
This class performs SPARQL queries for the WebIsALOD data set.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
      Default logger
    • synonymyAskBuffer

      private ConcurrentMap<StringString,Boolean> synonymyAskBuffer
      Synonymy Buffer
    • hypernymyAskBuffer

      private ConcurrentMap<StringString,Boolean> hypernymyAskBuffer
      Hypernymy Buffer (for ask queries)
    • hypernymBuffer

      private ConcurrentMap<String,Set<String>> hypernymBuffer
      Hypernym Buffer (for isa queries)
    • labelUriBuffer

      private ConcurrentMap<String,String> labelUriBuffer
      Label2URI buffer (linking buffer)
    • isDiskBufferEnabled

      private boolean isDiskBufferEnabled
      If the disk-buffer is disabled, no buffers are read/written from/to the disk. Default: true.
    • persistenceService

      private PersistenceService persistenceService
      Service responsible for disk buffers.
    • webIsAlodEndpoint

      private WebIsAlodSPARQLservice.WebIsAlodEndpoint webIsAlodEndpoint
      Instance Endpoint.
    • instances

      private static HashMap<String,WebIsAlodSPARQLservice> instances
      Singleton instances per endpoint.
    • CLASSIC_CONFIDENCE

      private static final String CLASSIC_CONFIDENCE
      See Also:
    • XL_CONFIDENCE

      private static final String XL_CONFIDENCE
      See Also:
    • isUseTdb

      private boolean isUseTdb
      True if a tdb source shall be used rather than an on-line SPARQL endpoint.
    • tdbDataset

      private org.apache.jena.query.Dataset tdbDataset
      The TDB dataset into which the DBpedia data set was loaded.
    • tdbModel

      private org.apache.jena.rdf.model.Model tdbModel
      TDB 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 WebIsAlodSPARQLservice(String tdbDirectoryPath, boolean isDiskBufferEnabled)
      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

      public static WebIsAlodSPARQLservice getInstance(String tdbDirectoryPath)
      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

      public boolean isConceptOnDataSet(String uri)
      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

      public boolean hasBroaderConcepts(String uri)
      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

      public boolean isSynonymous(String uri1, String uri2)
      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

      public boolean isSynonymous(String uri1, String uri2, double minimumConfidence)
      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

      public boolean isHypernymous(String uri1, String uri2, double minimumConfidence)
    • isHypernymous

      public boolean isHypernymous(String uri1, String uri2)
      Assumed minimum confidence: 0.0.
      Parameters:
      uri1 - URI 1
      uri2 - 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

      public Set<String> getHypernyms(String uri, double confidence)
      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

      private static String getIsSynonymousAskQueryClassic(String uri1, String uri2)
      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

      public static boolean isALODxlEndpointConcept(String uri)
      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

      public String getUriUsingLabel(String label)
      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

      public boolean isURIinDictionary(String uri)
      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

      public void commit(PersistenceService.PreconfiguredPersistences persistences)
    • 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.