Class DBpediaKnowledgeSource
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.SemanticWordRelationDictionary
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.dbpedia.DBpediaKnowledgeSource
- All Implemented Interfaces:
ExternalResource
,ExternalResourceWithHypernymCapability
,ExternalResourceWithSynonymCapability
,HypernymCapability
,SynonymCapability
DBpedia knowledge source.
Works with the online endpoint and TDB 1.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
The public SPARQL endpoint.DBpedia annotates quite a lot of hypernyms.(package private) ConcurrentMap<String,
Set<String>> Buffer for repeated hypernymy requests.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 DBpediaLinker
private static final org.slf4j.Logger
Logger for this class.private String
private PersistenceService
Service responsible for disk buffers.(package private) ConcurrentMap<String,
Set<String>> Buffer for repeated synonymy requests.private org.apache.jena.query.Dataset
The TDB dataset into which the DBpedia data set was loaded.private org.apache.jena.rdf.model.Model
TDB model -
Constructor Summary
ConstructorDescriptionDefault constructor.DBpediaKnowledgeSource
(boolean isDiskBufferEnabled) Constructor for SPARQL access.DBpediaKnowledgeSource
(String tdbDirectoryPath) Constructor for DBpedia TDB access.DBpediaKnowledgeSource
(String tdbDirectoryPath, boolean isDiskBufferEnabled) Constructor for DBpedia TDB access. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closing open resources.private void
Commit data changes if active.static String
getHypernyms
(String linkedConcept) Retrieves a set of hypernyms independently of the word sense.private String
getHypernymsQuery
(String linkedConcept) Construct a query for hypernyms.Returns the linker instance for this particular resource.getName()
Obtain the name of the resource.(package private) static StringBuilder
getSubjectPredicateQueryLineForConcepts
(String subject, String predicate) Helper method to build a query.(package private) static StringBuilder
getSubjectPredicateQueryLineForLabels
(String subject, String predicate) Helper method to build a query.getSynonymsLexical
(String linkedConcept) Retrieves a list of synonyms independently of the word sense.(package private) String
Builds a String query to obtain synonyms.org.apache.jena.query.Dataset
private void
Initialize buffers (either on-disk or memory).private void
private void
Helper method to initialize the linker.private void
Initializations that have to be performed.boolean
boolean
isHypernymous
(String linkedConcept_1, String linkedConcept_2) Checks for hypernymous words in a loose-form fashion: One concept needs to be a hypernym of the other concept where the order of concepts is irrelevant, i.e., the method returns (hypernymous(w1, w2) || hypernymous(w2, w1).boolean
isInDictionary
(String word) boolean
isStrongFormSynonymous
(String link1, String link2) Checks for synonymy by determining whether link1 is contained in the set of synonymous words of link2 or vice versa.boolean
isUseTdb()
void
setExcludedHypernyms
(Set<String> excludedHypernyms) Methods inherited from class de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.SemanticWordRelationDictionary
isHypernym, isHypernym, isSynonymous, isSynonymousOrHypernymous
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger for this class. -
ENDPOINT_URL
The public SPARQL endpoint.- See Also:
-
name
-
linker
-
synonymyBuffer
ConcurrentMap<String,Set<String>> synonymyBufferBuffer for repeated synonymy requests. -
hypernymyBuffer
ConcurrentMap<String,Set<String>> hypernymyBufferBuffer for repeated hypernymy requests. -
excludedHypernyms
DBpedia annotates quite a lot of hypernyms. Some of them may be misleading for some analyses such as "http://www.w3.org/2002/07/owl#Thing". -
persistenceService
Service responsible for disk buffers. -
isDiskBufferEnabled
private boolean isDiskBufferEnabledIf the disk-buffer is disabled, no buffers are read/written from/to the disk. Default: true. -
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
-
DBpediaKnowledgeSource
public DBpediaKnowledgeSource()Default constructor. SPARQL endpoint will be queried. Disk buffer is enabled by default. -
DBpediaKnowledgeSource
public DBpediaKnowledgeSource(boolean isDiskBufferEnabled) Constructor for SPARQL access.- Parameters:
isDiskBufferEnabled
- True if a disk buffer shall be enabled by default.
-
DBpediaKnowledgeSource
Constructor for DBpedia TDB access.- Parameters:
tdbDirectoryPath
- The path to the TDB directory.
-
DBpediaKnowledgeSource
Constructor for DBpedia TDB access.- Parameters:
tdbDirectoryPath
- The path to the TDB directory.isDiskBufferEnabled
- True if the disk buffer shall be enabled.
-
-
Method Details
-
getEndpointUrl
-
initializeMembers
private void initializeMembers()Initializations that have to be performed. -
initializeHypernymExclusion
private void initializeHypernymExclusion() -
initializeLinker
private void initializeLinker()Helper method to initialize the linker. -
initializeBuffers
private void initializeBuffers()Initialize buffers (either on-disk or memory). -
isInDictionary
-
isHypernymous
Checks for hypernymous words in a loose-form fashion: One concept needs to be a hypernym of the other concept where the order of concepts is irrelevant, i.e., the method returns (hypernymous(w1, w2) || hypernymous(w2, w1). The assumed language is English. CHECKS ONLY FOR LEVEL 1 HYPERNYMY - NO REASONING IS PERFORMED.- Specified by:
isHypernymous
in interfaceHypernymCapability
- Overrides:
isHypernymous
in classSemanticWordRelationDictionary
- Parameters:
linkedConcept_1
- linked word 1linkedConcept_2
- linked word 2- Returns:
- True if the given words are hypernymous, else false.
-
getSynonymsLexical
Description copied from class:SemanticWordRelationDictionary
Retrieves a list of synonyms independently of the word sense. The assumed language is English.- Specified by:
getSynonymsLexical
in interfaceSynonymCapability
- Specified by:
getSynonymsLexical
in classSemanticWordRelationDictionary
- Parameters:
linkedConcept
- The linked concept for which synonyms shall be retrieved.- Returns:
- A set of synonyms in word form (not links).
-
isStrongFormSynonymous
Checks for synonymy by determining whether link1 is contained in the set of synonymous words of link2 or vice versa.- Specified by:
isStrongFormSynonymous
in interfaceSynonymCapability
- Overrides:
isStrongFormSynonymous
in classSemanticWordRelationDictionary
- Parameters:
link1
- Word 1link2
- Word 2- Returns:
- True if the given words are synonymous, else false.
-
getSynonymsLexicalQuery
Builds a String query to obtain synonyms. The synonyms are represented by normal words/labels (not URIs).- Parameters:
link
- The link for which synonymous words shall be obtained.- Returns:
- A SPARQL query as String.
-
getSubjectPredicateQueryLineForLabels
Helper method to build a query.- Parameters:
subject
- The subjectpredicate
- The predicate.- Returns:
- A string builder.
-
getHypernyms
Description copied from class:SemanticWordRelationDictionary
Retrieves a set of hypernyms independently of the word sense. The assumed language is English.- Specified by:
getHypernyms
in classSemanticWordRelationDictionary
- Parameters:
linkedConcept
- The linked concept for which hypernyms shall be retrieved.- Returns:
- A set of linked concepts.
-
getHypernymsQuery
Construct a query for hypernyms.- Parameters:
linkedConcept
- The concept for which hypernyms shall be retrieved.- Returns:
- SPARQL query as String.
-
getSubjectPredicateQueryLineForConcepts
Helper method to build a query.- Parameters:
subject
- The subjectpredicate
- The predicate.- Returns:
- A string builder.
-
commitAll
private void commitAll()Commit data changes if active. -
close
public void close()Description copied from class:SemanticWordRelationDictionary
Closing open resources.- Specified by:
close
in classSemanticWordRelationDictionary
-
getLinker
Description copied from interface:ExternalResource
Returns the linker instance for this particular resource.- Specified by:
getLinker
in interfaceExternalResource
- Specified by:
getLinker
in classSemanticWordRelationDictionary
- Returns:
- The specific linker used to link words to concepts.
-
isUseTdb
public boolean isUseTdb() -
getTdbDataset
public org.apache.jena.query.Dataset getTdbDataset() -
getName
Description copied from interface:ExternalResource
Obtain the name of the resource.- Specified by:
getName
in interfaceExternalResource
- Specified by:
getName
in classSemanticWordRelationDictionary
- Returns:
- Name of the resource.
-
getExcludedHypernyms
-
isDiskBufferEnabled
public boolean isDiskBufferEnabled() -
setExcludedHypernyms
-