Class DBpediaLinker
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.dbpedia.DBpediaLinker
- All Implemented Interfaces:
LabelToConceptLinker
,MultiConceptLinker
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
The public SPARQL endpoint.private boolean
True if buffer shall be written/read to/from disk to reduce the number of queries sent out.private boolean
True if a TDB source shall be used rather than an on-line SPARQL endpoint.private static final org.slf4j.Logger
static final String
Universal prefix for multi concepts.private static ConcurrentMap<String,
Set<String>> Often, one label refers to multiple concepts.private String
(package private) PersistenceService
Service responsible for disk buffers.(package private) Set<StringModifier>
A set of string operations that are all performed.private org.apache.jena.query.Dataset
The TDB dataset into which the DBpedia data set was loaded. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
commit()
Commit data changes if active.static String
(package private) static String
getLinkerQueryString
(Set<String> concepts, Language language) SPARQL query to find links using a label and a language.Get instance specific name of the linker.(package private) static StringBuilder
getPredicateQueryLine
(String predicate, String concept, Language language) Helper method to build a query.Given a multiConceptLink, this method will return the individual links.Given a set of links where the links can be multi concept links or direct links, a set of only direct links is returned.private void
Initialization of buffers.boolean
boolean
isMultiConceptLink
(String link) Determine whether the link at hand is a multi-concept link.linkLabelToTokensLeftToRight
(String labelToBeLinked, Language language) Splits the labelToBeLinked in ngrams up to infinite size and tries to link components.linkToPotentiallyMultipleConcepts
(String labelToBeLinked) This method tries to linklabelToBeLinked
to one concept if possible.linkToPotentiallyMultipleConcepts
(String labelToBeLinked, Language language) linkToSingleConcept
(String labelToBeLinked) Link to a single concept.linkToSingleConcept
(String labelToBeLinked, Language language) Link to a single concept.void
setDiskBufferEnabled
(boolean diskBufferEnabled) void
setNameOfLinker
(String nameOfLinker) Set instance specific name of the linker.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
ENDPOINT_URL
The public SPARQL endpoint.- See Also:
-
nameOfLinker
-
MULTI_CONCEPT_PREFIX
Universal prefix for multi concepts.- See Also:
-
persistenceService
PersistenceService persistenceServiceService responsible for disk buffers. -
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 theMULTI_CONCEPT_PREFIX
. The data structure is also used as cache. -
isDiskBufferEnabled
private boolean isDiskBufferEnabledTrue if buffer shall be written/read to/from disk to reduce the number of queries sent out. -
stringModificationSet
Set<StringModifier> stringModificationSetA set of string operations that are all performed. -
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.
-
-
Constructor Details
-
DBpediaLinker
Constructor- Parameters:
dBpediaKnowledgeSource
- DBpedia knowledge source (configuration of the knowledge source will will be used).
-
-
Method Details
-
getEndpointUrl
-
getUris
Given a multiConceptLink, this method will return the individual links.- Specified by:
getUris
in interfaceMultiConceptLinker
- Parameters:
multiConceptLink
- The lookup link.- Returns:
- Individual links, empty set if there are none.
-
isMultiConceptLink
Description copied from interface:MultiConceptLinker
Determine whether the link at hand is a multi-concept link.- Specified by:
isMultiConceptLink
in interfaceMultiConceptLinker
- Parameters:
link
- Link to be checked.- Returns:
- True if multi-concept link, else false.
-
getUris
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
Link to a single concept. The assumed language is English.- Specified by:
linkToSingleConcept
in interfaceLabelToConceptLinker
- Parameters:
labelToBeLinked
- The label which shall be linked to a single concept.- Returns:
- Link. The link is not a URI.
-
linkToSingleConcept
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
- Parameters:
uri
- The URI for which a disambiguation shall be obtained.- Returns:
- A set of URIs. The set may be empty.
-
getLinkerQueryString
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
Helper method to build a query.- Parameters:
predicate
- The predicate.concept
- The concept String representation.language
- The language.- Returns:
- A string builder.
-
linkToPotentiallyMultipleConcepts
Description copied from interface:LabelToConceptLinker
This method tries to linklabelToBeLinked
to one concept if possible. If it fails, it will try to link it to multiple concepts.- Specified by:
linkToPotentiallyMultipleConcepts
in interfaceLabelToConceptLinker
- 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
-
linkLabelToTokensLeftToRight
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
Description copied from interface:LabelToConceptLinker
Get instance specific name of the linker.- Specified by:
getNameOfLinker
in interfaceLabelToConceptLinker
- Returns:
- Name as String.
-
setNameOfLinker
Description copied from interface:LabelToConceptLinker
Set instance specific name of the linker.- Specified by:
setNameOfLinker
in interfaceLabelToConceptLinker
- Parameters:
nameOfLinker
- Name to be set.
-
isDiskBufferEnabled
public boolean isDiskBufferEnabled() -
setDiskBufferEnabled
public void setDiskBufferEnabled(boolean diskBufferEnabled)
-