📄 racerclient.java
字号:
if (termParser!=null) termParser.parseConcept(c);
String res=send("(concept-synonyms "+c+")",true);
return parseList(res);
}
/** This method refers to the RACER concept-synonyms macro.
* @return String[] an array of strings containing the concept synonyms for cn.
* @param cn java.lang.String the concept name
* @param tbox java.lang.String The tbox
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public String[] conceptSynonyms(String c, String tbox) throws RacerException, IOException {
if (termParser!=null) termParser.parseConcept(c);
String res=send("(concept-synonyms "+c+" "+tbox+")",true);
return parseList(res);
}
/** This method creates a RacerTermParser that will be used to perform syntax checking on the concept and
role terms.
* @return jracer.RacerTermParser The term parser.
*/
protected RacerTermParser createTermParser() {
return new RacerTermParser();
}
/** This method refers to the RACER KRSS macro.
* @param cn java.lang.String The concept name being defined.
* @param c java.lang.String A concept term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void defineConcept(String cn, String c) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(cn);
if (termParser!=null) termParser.parseConcept(c);
send("(define-concept "+cn+" "+c+")",false);
}
/** This method refers to the RACER define-distinct-individual macro.
* @param in java.lang.String The name of the individual.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void defineDistinctIndividual(String in) throws java.io.IOException, RacerException {
send("(define-distinct-individual "+in+")",false);
}
/** This method refers to the RACER define-distinct-individual macro.
* @param in java.lang.String The name of the individual.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void defineDistinctIndividual(String in,String abox) throws java.io.IOException, RacerException {
send("(define-distinct-individual "+in+" "+abox+")",false);
}
/** This method refers to the RACER KRSS macro.
* @param cn java.lang.String The concept name being defined.
* @param c java.lang.String A concept term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void definePrimitiveConcept(String cn, String c) throws java.io.IOException, RacerException {
send("(define-primitive-concept "+cn+" "+c+")",false);
}
/** This method refers to the RACER define-primitive-role macro.
* @param role java.lang.String The role name, possibly extended with the RACER macro keywords.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void definePrimitiveRole(String role) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(role);
send("(define-primitive-role "+role+")",false);
}
/** This method refers to the RACER define-primitive-role macro. The RACER macro keywords have been
converted into method parameters. If some of the values for these keywords is the default value,
the corresponding parameter should be set to null.
* @param rn java.lang.String The role name.
* @param properties int An integer stating the properties of the role. It can be a bit-OR operation
of RacerConstants.TRANSITIVE_ROLE, RacerConstants.FEATURE, RacerConstants.SYMMETRIC_ROLE, and
RacerConstants.REFLEXIVE_ROLE. It can be also RacerConstants.PLAIN_ROLE, stating that the role
has none of the previous properties.
* @param inverse java.lang.String The name for the inverse role if supplied.
* @param domain java.lang.String The domain definition.
* @param range java.lang.String The range definition.
* @param parents java.lang.String A list of superroles for the role. The superroles are separated
by one or more spaces.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void definePrimitiveRole(String rn, int properties, String inverse, String domain, String range, String parents) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(rn);
String message="(define-primitive-role "+rn;
if ((properties & RacerConstants.TRANSITIVE_ROLE) != 0) message+=" :transitive t";
if ((properties & RacerConstants.FEATURE) != 0) message+=" :feature t";
if ((properties & RacerConstants.SYMMETRIC_ROLE) != 0) message+=" :symmetric t";
if ((properties & RacerConstants.REFLEXIVE_ROLE) != 0) message+=" :reflexive t";
if (inverse!=null) message+=" :inverse "+inverse;
if (domain!=null) message+=" :domain "+domain;
if (range!=null) message+=" :range "+range;
if (parents!=null) message+=" :parents "+parents;
message+=")";
send(message,false);
}
/** This method refers to the disjoint RACER macro
* @param cns java.lang.String A string containing the names of the concepts separated by one or more
spaces.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void disjoint(String cns) throws java.io.IOException, RacerException {
send("(disjoint "+cns+")",true);
}
/** This method refers to the RACER equivalent macro.
* @param c1 java.lang.String
* @param c2 java.lang.String
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void equivalent(String c1, String c2) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(c1);
if (termParser!=null) termParser.parseConcept(c2);
send("(equivalent "+c1+" "+c2+")",true);
}
/** This method refers to the feature-p RACER function.
* @return boolean true if r is a feature and false otherwise.
* @param r java.lang.String a role term.
* @param tbox java.lang.String tbox name.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public boolean featureP(String r, String tbox) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(feature-p "+r+" "+tbox+")",true);
return parseBoolean(res);
}
/** This method refers to the feature-p RACER function.
* @return boolean true if r is a feature and false otherwise.
* @param r java.lang.String a role term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public boolean featureP(String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(feature-p "+r+")",true);
return parseBoolean(res);
}
/** This method refers to the cd-attribute-p RACER function.
* @return boolean true if r is a concrete domain attribute and false otherwise.
* @param r java.lang.String a concrete domain attribute name.
* @param tbox java.lang.String tbox name.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public boolean CDattributeP(String r, String tbox) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseAttribute(r);
String res=send("(cd-attribute-p "+r+" "+tbox+")",true);
return parseBoolean(res);
}
/** This method refers to the cd-attribute-p RACER function.
* @return boolean true if r is a concrete domain attribute and false otherwise.
* @param r java.lang.String a concrete domain attribute name.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public boolean CDattributeP(String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseAttribute(r);
String res=send("(cd-attribute-p "+r+")",true);
return parseBoolean(res);
}
/** This method asserts a set of ABox statements.
* @param assertions jracer.Assertion[] The assertion array to be asserted.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void forget(Assertion[] assertions) throws java.io.IOException, RacerException {
String message="(forget";
for(int i=0;i<assertions.length;i++) message=message+" "+assertions[i];
send(message+")",false);
}
/** This method refers to the RACER forget-concept-assertion function. The assertion is removed from the
current abox.
* @param in java.lang.String The instance name.
* @param c java.lang.String The concept term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void forgetConceptAssertion(String in, String c) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(c);
send("(forget (instance "+in+" "+c+"))",false);
}
/** This method refers to the RACER forget-concept-assertion function.
* @param abox java.lang.String The abox name corresponding to the abox from which the assertion is to
be removed.
* @param in java.lang.String The individual name.
* @param c java.lang.String The concept term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void forgetConceptAssertion(String abox, String in, String c) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(c);
send("(forget-concept-assertion "+abox+" "+in+" "+c+")",false);
}
/** This method refers to the RACER forget-role-assertion function , in which the current abox is used.
* @param in1 java.lang.String Individual name of the predecessor.
* @param in2 java.lang.String Individual name of the successor.
* @param r java.lang.String A role term or a feature term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void forgetRoleAssertion(String in1, String in2, String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(r);
send("(forget (related "+in1+" "+in2+" "+r+"))",false);
}
/** This method refers to the RACER add-role-assertion function.
* @param abox java.lang.String The name of the abox from which the role assertion is to be removed.
* @param in1 java.lang.String The individual name of the predecessor.
* @param in2 java.lang.String The individual name of the successor.
* @param r java.lang.String The role term.
* @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
* @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
*/
public void forgetRoleAssertion(String abox, String in1, String in2, String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
send("(forget-role-assertion "+abox+" "+in1+" "+in2+" "+r+")",false);
}
/** This method returns the answer and warning messages from the RACER result.
* @return java.lang.String
* @param result java.lang.String
*/
protected String getError(String result) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -