knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::Vocabulary Class Reference

#include <Vocabulary.h>

Public Member Functions

 Vocabulary ()
 
 ~Vocabulary ()
 
void addResourceType (const std::string_view &resource_iri, const std::string_view &type_iri)
 
bool isDefinedClass (const std::string_view &iri)
 
semweb::ClassPtr getDefinedClass (const std::string_view &iri) const
 
std::vector< semweb::ClassPtrgetDefinedClassesWithPrefix (const std::string_view &prefix) const
 
std::vector< std::string_view > getDefinedClassNamesWithPrefix (const std::string_view &prefix) const
 
semweb::ClassPtr defineClass (const std::string_view &iri)
 
void addSubClassOf (const std::string_view &subClass, const std::string_view &superClass, std::optional< std::string_view > graph)
 
bool isSubClassOf (const std::string_view &subClass, const std::string_view &superClass)
 
bool isDefinedProperty (const std::string_view &iri)
 
bool isDefinedReification (const std::string_view &iri)
 
semweb::PropertyPtr getDefinedProperty (const std::string_view &iri) const
 
semweb::PropertyPtr getDefinedReification (const std::string_view &iri) const
 
std::vector< semweb::PropertyPtrgetDefinedPropertiesWithPrefix (const std::string_view &prefix) const
 
std::vector< std::string_view > getDefinedPropertyNamesWithPrefix (const std::string_view &prefix) const
 
semweb::PropertyPtr defineProperty (const std::string_view &iri)
 
semweb::PropertyPtr defineProperty (const IRIAtomPtr &iri)
 
void addSubPropertyOf (const std::string_view &subProperty, const std::string_view &superProperty, std::optional< std::string_view > graph)
 
void setInverseOf (const std::string_view &a, const std::string_view &b)
 
void setPropertyFlag (const std::string_view &iri, semweb::PropertyFlag flag)
 
void setPropertyFlag (const IRIAtomPtr &iri, semweb::PropertyFlag flag)
 
bool isAnnotationProperty (const std::string_view &iri)
 
bool isObjectProperty (const std::string_view &iri)
 
bool isDatatypeProperty (const std::string_view &iri)
 
void setFrequency (const std::string_view &iri, uint64_t frequency)
 
void increaseFrequency (const std::string_view &iri)
 
uint64_t frequency (const std::string_view &iri) const
 
const std::shared_ptr< ImportHierarchy > & importHierarchy () const
 
template<typename T >
std::shared_ptr< T > define (const std::string_view &iri)
 
 Vocabulary ()
 
 ~Vocabulary ()
 
void addResourceType (const std::string_view &resource_iri, const std::string_view &type_iri)
 
bool isDefinedClass (const std::string_view &iri)
 
semweb::ClassPtr getDefinedClass (const std::string_view &iri) const
 
std::vector< semweb::ClassPtrgetDefinedClassesWithPrefix (const std::string_view &prefix) const
 
std::vector< std::string_view > getDefinedClassNamesWithPrefix (const std::string_view &prefix) const
 
semweb::ClassPtr defineClass (const std::string_view &iri)
 
void addSubClassOf (const std::string_view &subClass, const std::string_view &superClass, std::optional< std::string_view > graph)
 
bool isSubClassOf (const std::string_view &subClass, const std::string_view &superClass)
 
bool isDefinedProperty (const std::string_view &iri)
 
bool isDefinedReification (const std::string_view &iri)
 
semweb::PropertyPtr getDefinedProperty (const std::string_view &iri) const
 
semweb::PropertyPtr getDefinedReification (const std::string_view &iri) const
 
std::vector< semweb::PropertyPtrgetDefinedPropertiesWithPrefix (const std::string_view &prefix) const
 
std::vector< std::string_view > getDefinedPropertyNamesWithPrefix (const std::string_view &prefix) const
 
semweb::PropertyPtr defineProperty (const std::string_view &iri)
 
semweb::PropertyPtr defineProperty (const IRIAtomPtr &iri)
 
void addSubPropertyOf (const std::string_view &subProperty, const std::string_view &superProperty, std::optional< std::string_view > graph)
 
void setInverseOf (const std::string_view &a, const std::string_view &b)
 
void setPropertyFlag (const std::string_view &iri, semweb::PropertyFlag flag)
 
void setPropertyFlag (const IRIAtomPtr &iri, semweb::PropertyFlag flag)
 
bool isAnnotationProperty (const std::string_view &iri)
 
bool isObjectProperty (const std::string_view &iri)
 
bool isDatatypeProperty (const std::string_view &iri)
 
void setFrequency (const std::string_view &iri, uint64_t frequency)
 
void increaseFrequency (const std::string_view &iri)
 
uint64_t frequency (const std::string_view &iri) const
 
const std::shared_ptr< ImportHierarchy > & importHierarchy () const
 
template<typename T >
std::shared_ptr< T > define (const std::string_view &iri)
 

Static Public Member Functions

static bool isTaxonomicProperty (const std::string_view &iri)
 
static bool isTaxonomicProperty (const std::string_view &iri)
 

Protected Member Functions

semweb::PropertyPtr defineProperty_ (const std::shared_ptr< semweb::Property > &p)
 
semweb::PropertyPtr defineProperty_ (const std::shared_ptr< semweb::Property > &p)
 

Protected Attributes

std::map< std::string_view, semweb::ClassPtr, std::less<> > definedClasses_
 
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedProperties_
 
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedReifications_
 
std::map< std::string_view, uint64_t > frequency_
 
std::shared_ptr< ImportHierarchyimportHierarchy_
 

Detailed Description

The vocabulary of a knowledge graph. It contains the definitions of classes and properties.

Definition at line 22 of file Vocabulary.h.

Constructor & Destructor Documentation

◆ Vocabulary() [1/2]

Vocabulary::Vocabulary ( )

Definition at line 18 of file Vocabulary.cpp.

19  : importHierarchy_(std::make_shared<ImportHierarchy>()) {
24 
29 }
std::shared_ptr< ImportHierarchy > importHierarchy_
Definition: Vocabulary.h:228
void setPropertyFlag(const std::string_view &iri, semweb::PropertyFlag flag)
Definition: Vocabulary.cpp:166
semweb::PropertyPtr defineProperty(const std::string_view &iri)
Definition: Vocabulary.cpp:136
const IRIAtomPtr inverseOf
Definition: owl.h:17
const IRIAtomPtr versionInfo
Definition: owl.h:16
const IRIAtomPtr type
Definition: rdf.h:15
const IRIAtomPtr subPropertyOf
Definition: rdfs.h:16
const IRIAtomPtr seeAlso
Definition: rdfs.h:18
const IRIAtomPtr label
Definition: rdfs.h:19
const IRIAtomPtr comment
Definition: rdfs.h:17
const IRIAtomPtr subClassOf
Definition: rdfs.h:15
@ ANNOTATION_PROPERTY
Definition: Property.h:22

◆ ~Vocabulary() [1/2]

Vocabulary::~Vocabulary ( )

Definition at line 31 of file Vocabulary.cpp.

31  {
32  for (auto &c : definedClasses_) {
33  c.second->detach();
34  }
35  for (auto &p : definedProperties_) {
36  p.second->detach();
37  p.second->reification()->detach();
38  }
39 }
std::map< std::string_view, semweb::ClassPtr, std::less<> > definedClasses_
Definition: Vocabulary.h:224
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedProperties_
Definition: Vocabulary.h:225

◆ Vocabulary() [2/2]

knowrob::Vocabulary::Vocabulary ( )

◆ ~Vocabulary() [2/2]

knowrob::Vocabulary::~Vocabulary ( )

Member Function Documentation

◆ addResourceType() [1/2]

void Vocabulary::addResourceType ( const std::string_view &  resource_iri,
const std::string_view &  type_iri 
)

Adds a new type assertion.

Parameters
resource_iria resource
type_irithe type of the resource

Definition at line 240 of file Vocabulary.cpp.

240  {
241  if (isObjectPropertyIRI(type_iri))
242  setPropertyFlag(resource_iri, OBJECT_PROPERTY);
243  else if (isDatatypePropertyIRI(type_iri))
244  setPropertyFlag(resource_iri, DATATYPE_PROPERTY);
245  else if (isAnnotationPropertyIRI(type_iri))
246  setPropertyFlag(resource_iri, ANNOTATION_PROPERTY);
247  else if (isReflexivePropertyIRI(type_iri))
248  setPropertyFlag(resource_iri, REFLEXIVE_PROPERTY);
249  else if (isTransitivePropertyIRI(type_iri))
250  setPropertyFlag(resource_iri, TRANSITIVE_PROPERTY);
251  else if (isSymmetricPropertyIRI(type_iri))
252  setPropertyFlag(resource_iri, SYMMETRIC_PROPERTY);
253  else if (isPropertyIRI(type_iri))
254  defineProperty(resource_iri);
255  else if (isClassIRI(type_iri))
256  defineClass(resource_iri);
257 }
semweb::ClassPtr defineClass(const std::string_view &iri)
Definition: Vocabulary.cpp:72
@ SYMMETRIC_PROPERTY
Definition: Property.h:26
@ TRANSITIVE_PROPERTY
Definition: Property.h:24
@ REFLEXIVE_PROPERTY
Definition: Property.h:25
bool isClassIRI(std::string_view iri)
Definition: owl.cpp:9
bool isSymmetricPropertyIRI(std::string_view iri)
Definition: owl.cpp:27
bool isDatatypePropertyIRI(std::string_view iri)
Definition: owl.cpp:18
bool isPropertyIRI(std::string_view iri)
Definition: rdf.cpp:12
bool isTransitivePropertyIRI(std::string_view iri)
Definition: owl.cpp:24
bool isReflexivePropertyIRI(std::string_view iri)
Definition: owl.cpp:30
bool isAnnotationPropertyIRI(std::string_view iri)
Definition: owl.cpp:21
bool isObjectPropertyIRI(std::string_view iri)
Definition: owl.cpp:15

◆ addResourceType() [2/2]

void knowrob::Vocabulary::addResourceType ( const std::string_view &  resource_iri,
const std::string_view &  type_iri 
)

Adds a new type assertion.

Parameters
resource_iria resource
type_irithe type of the resource

◆ addSubClassOf() [1/2]

void Vocabulary::addSubClassOf ( const std::string_view &  subClass,
const std::string_view &  superClass,
std::optional< std::string_view >  graph 
)

Adds subclass-of relation between two classes, and defines them if they are not yet defined.

Parameters
subClassa IRI
superClassa IRI
graphthe graph where the relation is defined.

Definition at line 83 of file Vocabulary.cpp.

84  {
85  defineClass(subClass)->addDirectParent(defineClass(superClass), graph);
86 }

◆ addSubClassOf() [2/2]

void knowrob::Vocabulary::addSubClassOf ( const std::string_view &  subClass,
const std::string_view &  superClass,
std::optional< std::string_view >  graph 
)

Adds subclass-of relation between two classes, and defines them if they are not yet defined.

Parameters
subClassa IRI
superClassa IRI
graphthe graph where the relation is defined.

◆ addSubPropertyOf() [1/2]

void Vocabulary::addSubPropertyOf ( const std::string_view &  subProperty,
const std::string_view &  superProperty,
std::optional< std::string_view >  graph 
)

Adds subproperty-of relation between two properties, and defines them if they are not yet defined.

Parameters
subPropertya IRI
superPropertya IRI
graphthe graph where the relation is defined.

Definition at line 174 of file Vocabulary.cpp.

175  {
176  defineProperty(subProperty)->addDirectParent(defineProperty(superProperty), graph);
177 }

◆ addSubPropertyOf() [2/2]

void knowrob::Vocabulary::addSubPropertyOf ( const std::string_view &  subProperty,
const std::string_view &  superProperty,
std::optional< std::string_view >  graph 
)

Adds subproperty-of relation between two properties, and defines them if they are not yet defined.

Parameters
subPropertya IRI
superPropertya IRI
graphthe graph where the relation is defined.

◆ define() [1/2]

template<typename T >
std::shared_ptr<T> knowrob::Vocabulary::define ( const std::string_view &  iri)

Define a new class if it has not been defined before.

Template Parameters
Tthe resource type (either Class or Property)
Parameters
iria IRI
Returns
the resource defined for the IRI

◆ define() [2/2]

template<typename T >
std::shared_ptr<T> knowrob::Vocabulary::define ( const std::string_view &  iri)

Define a new class if it has not been defined before.

Template Parameters
Tthe resource type (either Class or Property)
Parameters
iria IRI
Returns
the resource defined for the IRI

◆ defineClass() [1/2]

ClassPtr Vocabulary::defineClass ( const std::string_view &  iri)

Define a new class if it has not been defined before.

Parameters
iria IRI
Returns
the class defined for the IRI

Definition at line 72 of file Vocabulary.cpp.

72  {
73  auto it = definedClasses_.find(iri);
74  if (it == definedClasses_.end()) {
75  auto newClass = std::make_shared<Class>(iri);
76  definedClasses_[newClass->iri()] = newClass;
77  return newClass;
78  } else {
79  return it->second;
80  }
81 }
IRIAtomPtr iri(std::string_view ns, std::string_view name)
Definition: IRIAtom.cpp:62

◆ defineClass() [2/2]

semweb::ClassPtr knowrob::Vocabulary::defineClass ( const std::string_view &  iri)

Define a new class if it has not been defined before.

Parameters
iria IRI
Returns
the class defined for the IRI

◆ defineProperty() [1/4]

PropertyPtr Vocabulary::defineProperty ( const IRIAtomPtr iri)

Define a new property if it has not been defined before.

Parameters
iria IRI
Returns
the property defined for the IRI

Definition at line 145 of file Vocabulary.cpp.

145  {
146  auto it = definedProperties_.find(iri->stringForm());
147  if (it == definedProperties_.end()) {
148  return defineProperty_(std::make_shared<Property>(iri));
149  } else {
150  return it->second;
151  }
152 }
semweb::PropertyPtr defineProperty_(const std::shared_ptr< semweb::Property > &p)

◆ defineProperty() [2/4]

semweb::PropertyPtr knowrob::Vocabulary::defineProperty ( const IRIAtomPtr iri)

Define a new property if it has not been defined before.

Parameters
iria IRI
Returns
the property defined for the IRI

◆ defineProperty() [3/4]

PropertyPtr Vocabulary::defineProperty ( const std::string_view &  iri)

Define a new property if it has not been defined before.

Parameters
iria IRI
Returns
the property defined for the IRI

Definition at line 136 of file Vocabulary.cpp.

136  {
137  auto it = definedProperties_.find(iri);
138  if (it == definedProperties_.end()) {
139  return defineProperty_(std::make_shared<Property>(iri));
140  } else {
141  return it->second;
142  }
143 }

◆ defineProperty() [4/4]

semweb::PropertyPtr knowrob::Vocabulary::defineProperty ( const std::string_view &  iri)

Define a new property if it has not been defined before.

Parameters
iria IRI
Returns
the property defined for the IRI

◆ defineProperty_() [1/2]

semweb::PropertyPtr knowrob::Vocabulary::defineProperty_ ( const std::shared_ptr< semweb::Property > &  p)
protected

◆ defineProperty_() [2/2]

semweb::PropertyPtr knowrob::Vocabulary::defineProperty_ ( const std::shared_ptr< semweb::Property > &  p)
protected

◆ frequency() [1/2]

uint64_t Vocabulary::frequency ( const std::string_view &  iri) const

Returns the frequency of a resource reflecting how often it appears in the knowledge corpus.

Parameters
iria IRI
Returns
the frequency

Definition at line 234 of file Vocabulary.cpp.

234  {
235  auto it = frequency_.find(iri);
236  if (it == frequency_.end()) return 0;
237  else return it->second;
238 }
std::map< std::string_view, uint64_t > frequency_
Definition: Vocabulary.h:227

◆ frequency() [2/2]

uint64_t knowrob::Vocabulary::frequency ( const std::string_view &  iri) const

Returns the frequency of a resource reflecting how often it appears in the knowledge corpus.

Parameters
iria IRI
Returns
the frequency

◆ getDefinedClass() [1/2]

ClassPtr Vocabulary::getDefinedClass ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the class defined for the IRI or a null reference

Definition at line 45 of file Vocabulary.cpp.

45  {
46  auto it = definedClasses_.find(iri);
47  if (it == definedClasses_.end()) {
48  return {};
49  } else {
50  return it->second;
51  }
52 }

◆ getDefinedClass() [2/2]

semweb::ClassPtr knowrob::Vocabulary::getDefinedClass ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the class defined for the IRI or a null reference

◆ getDefinedClassesWithPrefix() [1/2]

std::vector< ClassPtr > Vocabulary::getDefinedClassesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known classes with matching prefix

Definition at line 54 of file Vocabulary.cpp.

54  {
55  auto range_it = definedClasses_.equal_range(PrefixProbe{prefix});
56  std::vector<ClassPtr> result;
57  for (auto it = range_it.first; it != range_it.second; ++it) {
58  result.push_back(it->second);
59  }
60  return result;
61 }
constexpr std::string_view prefix
Definition: owl.h:14

◆ getDefinedClassesWithPrefix() [2/2]

std::vector<semweb::ClassPtr> knowrob::Vocabulary::getDefinedClassesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known classes with matching prefix

◆ getDefinedClassNamesWithPrefix() [1/2]

std::vector< std::string_view > Vocabulary::getDefinedClassNamesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known class names with matching prefix

Definition at line 63 of file Vocabulary.cpp.

63  {
64  auto range_it = definedClasses_.equal_range(PrefixProbe{prefix});
65  std::vector<std::string_view> result;
66  for (auto it = range_it.first; it != range_it.second; ++it) {
67  result.push_back(it->first);
68  }
69  return result;
70 }

◆ getDefinedClassNamesWithPrefix() [2/2]

std::vector<std::string_view> knowrob::Vocabulary::getDefinedClassNamesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known class names with matching prefix

◆ getDefinedPropertiesWithPrefix() [1/2]

std::vector< PropertyPtr > Vocabulary::getDefinedPropertiesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known properties with matching prefix

Definition at line 118 of file Vocabulary.cpp.

118  {
119  auto range_it = definedProperties_.equal_range(PrefixProbe{prefix});
120  std::vector<PropertyPtr> result;
121  for (auto it = range_it.first; it != range_it.second; ++it) {
122  result.push_back(it->second);
123  }
124  return result;
125 }

◆ getDefinedPropertiesWithPrefix() [2/2]

std::vector<semweb::PropertyPtr> knowrob::Vocabulary::getDefinedPropertiesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known properties with matching prefix

◆ getDefinedProperty() [1/2]

PropertyPtr Vocabulary::getDefinedProperty ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the property defined for the IRI or a null reference

Definition at line 100 of file Vocabulary.cpp.

100  {
101  auto it = definedProperties_.find(iri);
102  if (it == definedProperties_.end()) {
103  return {};
104  } else {
105  return it->second;
106  }
107 }

◆ getDefinedProperty() [2/2]

semweb::PropertyPtr knowrob::Vocabulary::getDefinedProperty ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the property defined for the IRI or a null reference

◆ getDefinedPropertyNamesWithPrefix() [1/2]

std::vector< std::string_view > Vocabulary::getDefinedPropertyNamesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known property names with matching prefix

Definition at line 127 of file Vocabulary.cpp.

127  {
128  auto range_it = definedProperties_.equal_range(PrefixProbe{prefix});
129  std::vector<std::string_view> result;
130  for (auto it = range_it.first; it != range_it.second; ++it) {
131  result.push_back(it->first);
132  }
133  return result;
134 }

◆ getDefinedPropertyNamesWithPrefix() [2/2]

std::vector<std::string_view> knowrob::Vocabulary::getDefinedPropertyNamesWithPrefix ( const std::string_view &  prefix) const
Parameters
prefixa IRI prefix
Returns
all known property names with matching prefix

◆ getDefinedReification() [1/2]

PropertyPtr Vocabulary::getDefinedReification ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the property reified by the IRI or a null reference

Definition at line 109 of file Vocabulary.cpp.

109  {
110  auto it = definedReifications_.find(iri);
111  if (it == definedReifications_.end()) {
112  return {};
113  } else {
114  return it->second;
115  }
116 }
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedReifications_
Definition: Vocabulary.h:226

◆ getDefinedReification() [2/2]

semweb::PropertyPtr knowrob::Vocabulary::getDefinedReification ( const std::string_view &  iri) const
Parameters
iria IRI
Returns
the property reified by the IRI or a null reference

◆ importHierarchy() [1/2]

const std::shared_ptr<ImportHierarchy>& knowrob::Vocabulary::importHierarchy ( ) const
inline
Returns
the import hierarchy of this vocabulary

Definition at line 212 of file Vocabulary.h.

212 { return importHierarchy_; }

◆ importHierarchy() [2/2]

const std::shared_ptr<ImportHierarchy>& knowrob::Vocabulary::importHierarchy ( ) const
inline
Returns
the import hierarchy of this vocabulary

Definition at line 212 of file Vocabulary.h.

212 { return importHierarchy_; }

◆ increaseFrequency() [1/2]

void Vocabulary::increaseFrequency ( const std::string_view &  iri)

Increase the frequency of a resource by one reflecting that it appears one more time in the knowledge corpus.

Parameters
iria IRI

Definition at line 225 of file Vocabulary.cpp.

225  {
226  auto it = frequency_.find(iri);
227  if (it == frequency_.end()) {
228  setFrequency(iri, 1);
229  } else {
230  it->second++;
231  }
232 }
void setFrequency(const std::string_view &iri, uint64_t frequency)
Definition: Vocabulary.cpp:207

◆ increaseFrequency() [2/2]

void knowrob::Vocabulary::increaseFrequency ( const std::string_view &  iri)

Increase the frequency of a resource by one reflecting that it appears one more time in the knowledge corpus.

Parameters
iria IRI

◆ isAnnotationProperty() [1/2]

bool Vocabulary::isAnnotationProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined annotation property

Definition at line 186 of file Vocabulary.cpp.

186  {
187  auto it = definedProperties_.find(iri);
188  return it != definedProperties_.end() && it->second->hasFlag(ANNOTATION_PROPERTY);
189 }

◆ isAnnotationProperty() [2/2]

bool knowrob::Vocabulary::isAnnotationProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined annotation property

◆ isDatatypeProperty() [1/2]

bool Vocabulary::isDatatypeProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined data type property

Definition at line 196 of file Vocabulary.cpp.

196  {
197  auto it = definedProperties_.find(iri);
198  return it != definedProperties_.end() && it->second->hasFlag(DATATYPE_PROPERTY);
199 }

◆ isDatatypeProperty() [2/2]

bool knowrob::Vocabulary::isDatatypeProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined data type property

◆ isDefinedClass() [1/2]

bool Vocabulary::isDefinedClass ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined class

Definition at line 41 of file Vocabulary.cpp.

41  {
42  return definedClasses_.count(iri) > 0;
43 }

◆ isDefinedClass() [2/2]

bool knowrob::Vocabulary::isDefinedClass ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined class

◆ isDefinedProperty() [1/2]

bool Vocabulary::isDefinedProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined property

Definition at line 92 of file Vocabulary.cpp.

92  {
93  return definedProperties_.count(iri) > 0;
94 }

◆ isDefinedProperty() [2/2]

bool knowrob::Vocabulary::isDefinedProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined property

◆ isDefinedReification() [1/2]

bool Vocabulary::isDefinedReification ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined reification

Definition at line 96 of file Vocabulary.cpp.

96  {
97  return definedReifications_.count(iri) > 0;
98 }

◆ isDefinedReification() [2/2]

bool knowrob::Vocabulary::isDefinedReification ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined reification

◆ isObjectProperty() [1/2]

bool Vocabulary::isObjectProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined object property

Definition at line 191 of file Vocabulary.cpp.

191  {
192  auto it = definedProperties_.find(iri);
193  return it != definedProperties_.end() && it->second->hasFlag(OBJECT_PROPERTY);
194 }

◆ isObjectProperty() [2/2]

bool knowrob::Vocabulary::isObjectProperty ( const std::string_view &  iri)
Parameters
iria IRI
Returns
true if IRI is a defined object property

◆ isSubClassOf() [1/2]

bool Vocabulary::isSubClassOf ( const std::string_view &  subClass,
const std::string_view &  superClass 
)
Parameters
subClassa IRI
superClassa IRI
Returns
true if subClass is a subclass of superClass

Definition at line 88 of file Vocabulary.cpp.

88  {
89  return defineClass(subClass)->isSubClassOf(defineClass(superClass));
90 }

◆ isSubClassOf() [2/2]

bool knowrob::Vocabulary::isSubClassOf ( const std::string_view &  subClass,
const std::string_view &  superClass 
)
Parameters
subClassa IRI
superClassa IRI
Returns
true if subClass is a subclass of superClass

◆ isTaxonomicProperty() [1/2]

bool Vocabulary::isTaxonomicProperty ( const std::string_view &  iri)
static
Parameters
iria IRI
Returns
true if IRI is a defined taxonomic property

Definition at line 201 of file Vocabulary.cpp.

201  {
202  return isSubClassOfIRI(iri) ||
204  isTypeIRI(iri);
205 }
bool isSubClassOfIRI(std::string_view iri)
Definition: rdfs.cpp:9
bool isTypeIRI(std::string_view iri)
Definition: rdf.cpp:9
bool isSubPropertyOfIRI(std::string_view iri)
Definition: rdfs.cpp:12

◆ isTaxonomicProperty() [2/2]

static bool knowrob::Vocabulary::isTaxonomicProperty ( const std::string_view &  iri)
static
Parameters
iria IRI
Returns
true if IRI is a defined taxonomic property

◆ setFrequency() [1/2]

void Vocabulary::setFrequency ( const std::string_view &  iri,
uint64_t  frequency 
)

Set the frequency of a resource reflecting how often it appears in the knowledge corpus.

Parameters
iria IRI
frequencya frequency

Definition at line 207 of file Vocabulary.cpp.

207  {
208  if (frequency == 0) {
209  frequency_.erase(iri);
210  } else {
211  auto p_it = definedProperties_.find(iri);
212  if (p_it != definedProperties_.end()) {
213  frequency_[p_it->second->iri()] = frequency;
214  return;
215  }
216  auto c_it = definedClasses_.find(iri);
217  if (c_it != definedClasses_.end()) {
218  frequency_[c_it->second->iri()] = frequency;
219  return;
220  }
221  KB_WARN("cannot set frequency of unknown resource '{}'", iri);
222  }
223 }
#define KB_WARN
Definition: Logger.h:27
uint64_t frequency(const std::string_view &iri) const
Definition: Vocabulary.cpp:234

◆ setFrequency() [2/2]

void knowrob::Vocabulary::setFrequency ( const std::string_view &  iri,
uint64_t  frequency 
)

Set the frequency of a resource reflecting how often it appears in the knowledge corpus.

Parameters
iria IRI
frequencya frequency

◆ setInverseOf() [1/2]

void Vocabulary::setInverseOf ( const std::string_view &  a,
const std::string_view &  b 
)

Define inverseOf relation between properties.

Parameters
aa property IRI
ba property IRI

Definition at line 179 of file Vocabulary.cpp.

179  {
180  auto a1 = defineProperty(a);
181  auto b1 = defineProperty(b);
182  a1->setInverse(b1);
183  b1->setInverse(a1);
184 }

◆ setInverseOf() [2/2]

void knowrob::Vocabulary::setInverseOf ( const std::string_view &  a,
const std::string_view &  b 
)

Define inverseOf relation between properties.

Parameters
aa property IRI
ba property IRI

◆ setPropertyFlag() [1/4]

void Vocabulary::setPropertyFlag ( const IRIAtomPtr iri,
semweb::PropertyFlag  flag 
)
Parameters
iria property IRI
flaga property flag

Definition at line 170 of file Vocabulary.cpp.

170  {
171  defineProperty(iri)->setFlag(flag);
172 }

◆ setPropertyFlag() [2/4]

void knowrob::Vocabulary::setPropertyFlag ( const IRIAtomPtr iri,
semweb::PropertyFlag  flag 
)
Parameters
iria property IRI
flaga property flag

◆ setPropertyFlag() [3/4]

void Vocabulary::setPropertyFlag ( const std::string_view &  iri,
semweb::PropertyFlag  flag 
)
Parameters
iria property IRI
flaga property flag

Definition at line 166 of file Vocabulary.cpp.

166  {
167  defineProperty(iri)->setFlag(flag);
168 }

◆ setPropertyFlag() [4/4]

void knowrob::Vocabulary::setPropertyFlag ( const std::string_view &  iri,
semweb::PropertyFlag  flag 
)
Parameters
iria property IRI
flaga property flag

Member Data Documentation

◆ definedClasses_

std::map< std::string_view, semweb::ClassPtr, std::less<> > knowrob::Vocabulary::definedClasses_
protected

Definition at line 224 of file Vocabulary.h.

◆ definedProperties_

std::map< std::string_view, semweb::PropertyPtr, std::less<> > knowrob::Vocabulary::definedProperties_
protected

Definition at line 225 of file Vocabulary.h.

◆ definedReifications_

std::map< std::string_view, semweb::PropertyPtr, std::less<> > knowrob::Vocabulary::definedReifications_
protected

Definition at line 226 of file Vocabulary.h.

◆ frequency_

std::map< std::string_view, uint64_t > knowrob::Vocabulary::frequency_
protected

Definition at line 227 of file Vocabulary.h.

◆ importHierarchy_

std::shared_ptr< ImportHierarchy > knowrob::Vocabulary::importHierarchy_
protected

Definition at line 228 of file Vocabulary.h.


The documentation for this class was generated from the following files: