Class BabelNetLinker
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.babelnet.BabelNetLinker
- All Implemented Interfaces:
LabelToConceptLinker
Links concepts to BabelNet (using the BabelNet indices).
-
Field Summary
Modifier and TypeFieldDescriptionprivate BabelNetKnowledgeSource
KnowledgeSource used for lookups.private static org.slf4j.Logger
private ConcurrentMap<String,
Set<String>> Buffer forlinkToPotentiallyMultipleConcepts(String)
Method.private String
Default name of the linker.private static final String
You cannot add null to a concurrent HashMap.private PersistenceService
Managing buffers.private ConcurrentMap<String,
String> Buffer forlinkToSingleConcept(String)
Method. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet instance specific name of the linker.private void
Initializes local databaselinkLabelToTokensLeftToRight
(String labelToBeLinked) 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.linkToSingleConcept
(String labelToBeLinked) Queries for a concept and returns a link that represents an entity in the background knowledge source such as theSemanticWordRelationDictionary
.static String
normalizeForBabelnetLookupWithoutTokenization
(String lookupString) Normalize for BabelNet lookup, i.e., lowercasing and camel-case resolution.static String
normalizeForBabelnetLookupWithTokenization
(String lookupString) Normalize for BabelNet lookup, i.e., lowercasing and camel-case resolution.void
setNameOfLinker
(String nameOfLinker) Set instance specific name of the linker.
-
Field Details
-
LOGGER
private static org.slf4j.Logger LOGGER -
nameOfLinker
Default name of the linker. -
dictionary
KnowledgeSource used for lookups. -
singleConceptBuffer
Buffer forlinkToSingleConcept(String)
Method. -
multipleConceptBuffer
Buffer forlinkToPotentiallyMultipleConcepts(String)
Method. -
persistenceService
Managing buffers. -
NULL_CHARACTER
You cannot add null to a concurrent HashMap. Therefore, a null character is added rather than null.- See Also:
-
-
Constructor Details
-
BabelNetLinker
Constructor- Parameters:
dictionary
- BabelNetKnowledgeSource instance that is to be used.
-
-
Method Details
-
initializeBuffers
private void initializeBuffers()Initializes local database -
linkToSingleConcept
Description copied from interface:LabelToConceptLinker
Queries for a concept and returns a link that represents an entity in the background knowledge source such as theSemanticWordRelationDictionary
. Note that the link may not always be something intuitive such as a URI but may also be an artificial identifier that is understood by the corresponding background knowledge source.- Specified by:
linkToSingleConcept
in interfaceLabelToConceptLinker
- Parameters:
labelToBeLinked
- The label which shall be linked to a single concept.- Returns:
- Concept or null if no link could be found.
-
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.
-
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.- Returns:
- A set of concept URIs that were found.
-
normalizeForBabelnetLookupWithTokenization
Normalize for BabelNet lookup, i.e., lowercasing and camel-case resolution. Dev-Remark: The BabelNet library utilizes space-separation.- Parameters:
lookupString
- The string that shall be normalized for lookup.- Returns:
- Space-separated lookup word.
-
normalizeForBabelnetLookupWithoutTokenization
Normalize for BabelNet lookup, i.e., lowercasing and camel-case resolution. Dev-Remark: The BabelNet library utilizes space-separation.- Parameters:
lookupString
- The string that shall be normalized for lookup.- Returns:
- Space-separated lookup word.
-
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.
-