java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.dbpedia.DBpediaLinker
All Implemented Interfaces:
LabelToConceptLinker, MultiConceptLinker

public class DBpediaLinker extends Object implements LabelToConceptLinker, MultiConceptLinker
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • ENDPOINT_URL

      private static final String ENDPOINT_URL
      The public SPARQL endpoint.
      See Also:
    • nameOfLinker

      private String nameOfLinker
    • MULTI_CONCEPT_PREFIX

      public static final String MULTI_CONCEPT_PREFIX
      Universal prefix for multi concepts.
      See Also:
    • persistenceService

      PersistenceService persistenceService
      Service responsible for disk buffers.
    • multiLinkStore

      private static ConcurrentMap<String,Set<String>> multiLinkStore
      Often, one label refers to multiple concepts. Hence, they are summarized in this data structure with the multi-concept as key. A multi-concept must start with the MULTI_CONCEPT_PREFIX. The data structure is also used as cache.
    • isDiskBufferEnabled

      private boolean isDiskBufferEnabled
      True if buffer shall be written/read to/from disk to reduce the number of queries sent out.
    • stringModificationSet

      Set<StringModifier> stringModificationSet
      A set of string operations that are all performed.
    • 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.
  • Constructor Details

    • DBpediaLinker

      public DBpediaLinker(DBpediaKnowledgeSource dBpediaKnowledgeSource)
      Constructor
      Parameters:
      dBpediaKnowledgeSource - DBpedia knowledge source (configuration of the knowledge source will will be used).
  • Method Details

    • getEndpointUrl

      public static String getEndpointUrl()
    • getUris

      @NotNull public @NotNull Set<String> getUris(String multiConceptLink)
      Given a multiConceptLink, this method will return the individual links.
      Specified by:
      getUris in interface MultiConceptLinker
      Parameters:
      multiConceptLink - The lookup link.
      Returns:
      Individual links, empty set if there are none.
    • isMultiConceptLink

      public boolean isMultiConceptLink(String link)
      Description copied from interface: MultiConceptLinker
      Determine whether the link at hand is a multi-concept link.
      Specified by:
      isMultiConceptLink in interface MultiConceptLinker
      Parameters:
      link - Link to be checked.
      Returns:
      True if multi-concept link, else false.
    • getUris

      public Set<String> getUris(Set<String> multipleLinks)
      Given a set of links where the links can be multi concept links or direct links, a set of only direct links is returned.
      Parameters:
      multipleLinks - Set with multiple links. Multi concept links can be mixed with direct links.
      Returns:
      A set with only direct links.
    • initializeBuffers

      private void initializeBuffers()
      Initialization of buffers.
    • linkToSingleConcept

      public String linkToSingleConcept(String labelToBeLinked)
      Link to a single concept. The assumed language is English.
      Specified by:
      linkToSingleConcept in interface LabelToConceptLinker
      Parameters:
      labelToBeLinked - The label which shall be linked to a single concept.
      Returns:
      Link. The link is not a URI.
    • linkToSingleConcept

      public String linkToSingleConcept(String labelToBeLinked, Language language)
      Link to a single concept. The assumed language is English.
      Parameters:
      labelToBeLinked - The label which shall be linked to a single concept.
      language - Language
      Returns:
      Link. The link is not a URI.
    • commit

      private void commit()
      Commit data changes if active.
    • getDisambiguationUris

      @NotNull public @NotNull Set<String> getDisambiguationUris(String uri)
      Parameters:
      uri - The URI for which a disambiguation shall be obtained.
      Returns:
      A set of URIs. The set may be empty.
    • getLinkerQueryString

      static String getLinkerQueryString(Set<String> concepts, Language language)
      SPARQL query to find links using a label and a language.
      Parameters:
      concepts - The concepts for which shall be looked.
      language - The language of the label.
      Returns:
      SPARQL String that can be executed.
    • getPredicateQueryLine

      static StringBuilder getPredicateQueryLine(String predicate, String concept, Language language)
      Helper method to build a query.
      Parameters:
      predicate - The predicate.
      concept - The concept String representation.
      language - The language.
      Returns:
      A string builder.
    • linkToPotentiallyMultipleConcepts

      public Set<String> linkToPotentiallyMultipleConcepts(String labelToBeLinked)
      Description copied from interface: LabelToConceptLinker
      This method tries to link labelToBeLinked to one concept if possible. If it fails, it will try to link it to multiple concepts.
      Specified by:
      linkToPotentiallyMultipleConcepts in interface LabelToConceptLinker
      Parameters:
      labelToBeLinked - The label which shall be linked.
      Returns:
      One or multiple linked concepts in a set. Null if it could not fully link the label.
    • linkToPotentiallyMultipleConcepts

      public HashSet<String> linkToPotentiallyMultipleConcepts(String labelToBeLinked, Language language)
    • linkLabelToTokensLeftToRight

      private HashSet<String> linkLabelToTokensLeftToRight(String labelToBeLinked, Language language)
      Splits the labelToBeLinked in ngrams up to infinite size and tries to link components. This corresponds to a MAXGRAM_LEFT_TO_RIGHT_TOKENIZER or NGRAM_LEFT_TO_RIGHT_TOKENIZER OneToManyLinkingStrategy.
      Parameters:
      labelToBeLinked - The label that shall be linked.
      language - The language of the label.
      Returns:
      A set of concept URIs that were found.
    • getNameOfLinker

      public String getNameOfLinker()
      Description copied from interface: LabelToConceptLinker
      Get instance specific name of the linker.
      Specified by:
      getNameOfLinker in interface LabelToConceptLinker
      Returns:
      Name as String.
    • setNameOfLinker

      public void setNameOfLinker(String nameOfLinker)
      Description copied from interface: LabelToConceptLinker
      Set instance specific name of the linker.
      Specified by:
      setNameOfLinker in interface LabelToConceptLinker
      Parameters:
      nameOfLinker - Name to be set.
    • isDiskBufferEnabled

      public boolean isDiskBufferEnabled()
    • setDiskBufferEnabled

      public void setDiskBufferEnabled(boolean diskBufferEnabled)