CLASS armor_cluedo.cpp
class aRMOR CLuedo – header
additional aRMOR C++ interface
See also
See also
- Authors
- Francesco Ganci (S4143910) 
- Version
- v1.0 
- 
class ArmorCluedo : public ArmorTools, public ArmorTools
- #include <armor_cluedo.h>additional utilities for aRMOR Whereas the class ArmorTools provides the low-level tools for communicating with aRMOR, the class ArmorCluedo implements some specific methods for this project, and sme workaround due to some bugs in the actual implementation of aRMOR, in particular for the commands “REMOVE” and “DISJOINT”. The class ArmorCluedo provides methods for doing these operations: - add individuals 
- check existence of individuals 
- find the classes of an individual 
- find the content of a class 
- set/get properties 
 - add hypotheses 
- queries of hypotheses 
- discard hypotheses 
 - Todo:
- maybe the issues with aRMOR are due to a lack in its documentation. The implemented workarounds could reduce the performances of the program. 
 Public Functions - 
ArmorCluedo(bool debugmode = ARMOR_DEFAULT_DEBUGMODE)
- class constructor of ArmorCluedo - The constrctor simply instanciates the internal data structures and the ArmorTools class, without connection and loading phases. - Parameters
- debugmode – enable or not debug mode; see ARMOR_DEFAULT_DEBUGMODE 
 
 - 
~ArmorCluedo()
- class destructor 
 - 
bool Init(std::string ontologyPath)
- initizalize the interface - The function performs both the first steps: connection to the aRMOR service, and the load of the file. A default loading phase is executed, with settings: No other types of initializations are needed right now by the project. - See also - the official aRMOR documentation for more informations - Note - If you need to initialize the interface in another way, you still can call the methods inside ArmorTools and setup the connection in the proper way. - Parameters
- ontologyPath – the path of the .owl file 
- Returns
- success or not 
 
 - 
bool AddIndiv(std::string indivname, std::string classname, bool makeDisjoint = true)
- add an individual to the ontology - In simple words, this function adds the individual to the database. - Due to the need of the command “DISJOINT” in order to make the reasoner able to classify the hypotheses, and due to an issue with the command “DISJOINT IND CLASS”, this function works in a more complex way. Here is how it works: - before starting, if the individual has class HYPOTHESIS and was discarded, return false immediately 
- The individual is tracked, i.e. put into an array which contains all the defined individuals 
- then, the individual is added 
- call the command “REASON” 
- if the last argument makeDisjoint is ture, the function also performs “DISJOINT” between the element to add and all the other elements. It is the only working and reliable way to ensure a correct classification by the reasoner right now. 
 - Since in RCL, the hypotheses are the only individuals with properties, there’s no need to DISJOINT them. Hence, that last option can be useful to reduce the complexity of the method: if makeDisjoint is set to false, the function doesn’t perform the last step. The element is tracked anyway. - Warning - remember: call upload before any manipolation command! - Parameters
- indivname – the individual to add 
- classname – the class of the individual to add 
- makeDisjoint – perform disjoint or not? 
 
- Returns
- true if the individual doesn’t appear in the database; false otherwise 
 
 - 
std::vector<std::string> GetClassOfIndiv(std::string indivname, bool deep)
- get the class of a given individual - The function implements a simple query: find all the classes an individual belongs to. It is performed using only one aRMOR call. - using the Deep search, the function will return only the deepest subclass among all the classes; it is a functionality provided by aRMOR. - Parameters
- indivname – the individual to be “classified” 
- deep – use deep search? 
 
- Returns
- a vector of classes (zero if the indiv. doesn’t exist) 
 
 - 
std::vector<std::string> GetIndivOfClass(std::string classname)
- find the individuals belonging to a class - Warning - The element also returns the discarded hypotheses. Don’t use this method for inspecting the hypotheses! - Parameters
- classname – the class 
- Returns
- a vector of individals inside the class (eventually empty) 
 
 - 
bool ExistsIndiv(std::string indivname)
- check if an individual exists - Parameters
- indivname – the name of the individual 
- Returns
- if the individual exists or not; false if the individual is a discarded hypothesis. 
 
 - 
bool SetObjectProperty(std::string prop, std::string Aelem, std::string Belem)
- set a property true - The function sets a property like (Aelem, Belem):prop . - Note - if the prop is not valid, the aRMOR call will fail, hence the method returns false. - Parameters
- prop – the property to set 
- Aelem – the domain 
- Belem – the image 
 
- Returns
- false if one between Aelem and Belem doesn’t exist. 
 
 - 
std::vector<std::string> GetValuedOfIndiv(std::string prop, std::string indivname)
- get the values of a property related to a gven individual - Given a set of properties like (indivname, value):prop, the method retrieves all the fields ‘value’. - Parameters
- prop – the property 
- indivname – the name of the individual 
 
- Returns
- the values of the property for the given individual 
 
 - 
std::vector<std::string> FindCompleteHypotheses()
- find all the complete hypotheses - The methos finds all the COMPLETE hypotheses, except for the discarded ones. - See also - ServiceFindConsistentHypotheses an example of usage - Returns
- a vector containing the tags of all the COMPLETE hyp. 
 
 - 
std::vector<std::string> FindInconsistentHypotheses()
- find all the inconsistent hypotheses - See also - ServiceFindConsistentHypotheses an example of usage - Note - This method doesn’t perform any filtering on the tags, so the output is exactly the individuals belonging to INCONSISTENT without deleting the discarded hypotheses. I recommend to not use this method, except for some cases. - Returns
- a vector containing the tags of all the INCONSISTENT hyp. 
 
 - 
bool RemoveHypothesis(std::string hypTag)
- discard one hypothesis - Due to an issue of the implementation of aRMOR, the command “REMOVE - IND CLASS” has no effect on the ontology. So, a workaround has been implemented. The class tracks the hypothesis as discarded; all the other methods are implemented in a way such that a discarded hypothesis doesn’t appear anymore as complete or existing. the discarded hypothesis is still in the ontology, but will be discarded with a post filtering, or will become inconsistent.- In RCL there’s no need to reconsider hypotheses, so, in this specific context, this approach works well. - Parameters
- hypTag – the hypothesis tag to discard 
- Returns
- if the hypothesis has been discarded or not; false if the hypothesis wasn’t defined before. 
 
 - 
std::string FilterValue(std::string raw)
- rewrite a string like ‘<uri#value>’ into ‘value’ - Parameters
- raw – the string to be filtered 
- Returns
- the value inside the string 
 
 - 
std::vector<std::string> FilterVector(std::vector<std::string> &itemlist)
- filter all the strings inside the array - It simply extends the method ArmorCluedo::FilterValue to an array of strings to be filtered. - Parameters
- itemList – the array of strings to be filtered 
- Returns
- the array containing the filtered strings 
 
 
class aRMOR CLuedo – cpp implementation
implementation of the class ArmorCluedo
See also
armor_cluedo.h
- Author
- Francesco Ganci (S4143910) 
- Version
- v1.0