📄 racerclient.java
字号:
String s=new String();
int iniMessage=result.indexOf(' ',7);
int ini=result.indexOf('"',iniMessage);
int fi=result.indexOf('"',ini+1);
s=iniMessage+1<ini-1 ? result.substring(iniMessage+1,ini-1) : "";
if (iniMessage+1<ini-1 && ini+1<fi) s=s+". ";
s=s+result.substring(ini+1,fi);
return s;
}
/** This method returns the answer and warning messages from the RACER result.
* @return java.lang.String
* @param result java.lang.String
*/
protected String[] getResultAndWarningFromAnswer(String result) {
String[] s=new String[2];
int ini=result.indexOf('"',10);
int fi=ini;
boolean esFinal=false;
while (!esFinal) {
fi=result.indexOf('"',fi+1);
esFinal=result.charAt(fi-1)!='\\';
}
s[0]=result.substring(ini+1,fi);
if (fi+4<result.length()) s[1]=result.substring(fi+3,result.length()-1);
return s;
}
/** This method returns the answer and warning messages from the RACER result.
* @return java.lang.String
* @param result java.lang.String
*/
protected String getWarningFromOK(String result) {
String warning=null;
int ini=result.indexOf('"',6);
int fi=result.length()-1;
if (ini<fi-1) warning=result.substring(ini+1,fi);
return warning;
}
/** This method refers to the RACER implies macro.
* @param c1 java.lang.String The subsumee
* @param c2 java.lang.String The subsumer
* @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 implies(String c1, String c2) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(c1);
if (termParser!=null) termParser.parseConcept(c2);
send("(implies "+c1+" "+c2+")",false);
}
/** This method refers to the in-abox RACER macro.
* @param abn java.lang.String The name of the ABox
* @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 inAbox(String abn) throws IOException, RacerException {
send("(in-abox "+abn+")",false);
}
/** This method refers to the in-abox RACER macro.
* @param abn java.lang.String The name of the ABox
* @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 inAbox(String abn,String tbn) throws IOException, RacerException {
send("(in-abox "+abn+" "+tbn+")",false);
}
/** This method refers to the RACER clone-abox macro.
* @return java.lang.String The name of the clone
* @param abn java.lang.String The name of the ABox
* @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 cloneABox(String abn) throws RacerException, IOException {
String res=send("(clone-abox "+abn+")",true);
return res;
}
/** This method refers to the RACER clone-abox macro.
* @return java.lang.String The name of the clone
* @param abn java.lang.String The name of the ABox
* @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 cloneABox(String abn,String newabn) throws RacerException, IOException {
String res=send("(clone-abox "+abn+" :new-name "+newabn+")",true);
return res;
}
/** This method refers to the RACER clone-abox macro.
* @return java.lang.String The name of the clone
* @param abn java.lang.String The name of the ABox
* @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 cloneABox(String abn,boolean overwrite) throws RacerException, IOException {
String res=send("(clone-abox "+abn+" :overwrite "+(overwrite ? "t" : "nil")+")",true);
return res;
}
/** This method refers to the RACER clone-abox macro.
* @return java.lang.String The name of the clone
* @param abn java.lang.String The name of the ABox
* @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 cloneABox(String abn,String newabn,boolean overwrite) throws RacerException, IOException {
String res=send("(clone-abox "+abn+" :new-name "+newabn+
" :overwrite "+(overwrite ? "t" : "nil")+")",true);
return res;
}
/** This method refers to the RACER delete-abox macro.
* @return java.lang.String The name of the deleted ABox
* @param abn java.lang.String The name of the ABox
* @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 deleteABox(String abn) throws RacerException, IOException {
String res=send("(delete-abox "+abn+")",true);
return res;
}
/** This method refers to the RACER delete-all-aboxes macro.
* @return 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 deleteAllABoxes() throws RacerException, IOException {
send("(delete-all-aboxes)",false);
}
/** This method refers to the RACER individual-direct-types macro.
* @return java.lang.String[] A list of concept names (one concept name for every concept equivalence
set returned by RACER).
* @param in java.lang.String The individual names.
* @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[] individualDirectTypes(String in) throws java.io.IOException, RacerException {
String res=send("(individual-direct-types "+in+")",true);
return parseConceptSetList(res);
}
/** This method refers to the RACER individual-direct-types macro.
* @return java.lang.String[] A list of concept names (one concept name for every concept equivalence
set returned by RACER).
* @param in java.lang.String The individual names.
* @param abox java.lang.String The abox 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 String[] individualDirectTypes(String in,String abox) throws java.io.IOException, RacerException {
String res=send("(individual-direct-types "+in+" "+abox+")",true);
return parseConceptSetList(res);
}
/** This method refers to the RACER individual-equal? macro for the current abox.
* @return boolean True if in1 is equal to in2, and false otherwise.
* @param in1 java.lang.String The name of one individual.
* @param in2 java.lang.String The name of the other 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 boolean individualEqualP(String in1, String in2) throws java.io.IOException, RacerException {
String res=send("(individual-equal? "+in1+" "+in2+")",true);
return parseBoolean(res);
}
/** This method refers to the RACER individual-equal? macro.
* @return boolean True if in1 is equal to in2, and false otherwise.
* @param in1 java.lang.String The name of one individual.
* @param in2 java.lang.String The name of the other individual.
* @param abox java.lang.String The abox 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 individualEqualP(String in1, String in2, String abox) throws java.io.IOException, RacerException {
String res=send("(individual-equal? "+in1+" "+in2+" "+abox+")",true);
return parseBoolean(res);
}
/** This method refers to the RACER individual-fillers macro. The current abox is used.
* @return java.lang.String[] An array containing individual names.
* @param in java.lang.String The name of the predecessor individual.
* @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 String[] individualFillers(String in, String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(individual-fillers "+in+" "+r+")",true);
return parseList(res);
}
public String[] individualAttributeFillers(String in, String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(individual-attribute-fillers "+in+" "+r+")",true);
System.out.println(res);
return parseList(res);
}
public String[] individualDatatypeFillers(String in, String r) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(individual-told-datatype-fillers "+in+" "+r+")",true);
System.out.println(res);
return parseList(res);
}
/** This method refers to the RACER individual-fillers macro.
* @return java.lang.String[] An array containing individual names.
* @param in java.lang.String The name of the predecessor individual.
* @param r java.lang.String The role term.
* @param abox java.lang.String The name of the abox.
* @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[] individualFillers(String in, String r, String abox) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseRole(r);
String res=send("(individual-fillers "+in+" "+r+" "+abox+")",true);
return parseList(res);
}
/** This method refers to the RACER individual-instance? macro in which the current abox is used.
* @return boolean true if in is an instance of c in the abox, and false otherwise.
* @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 boolean individualInstanceP(String in, String c) throws java.io.IOException, RacerException {
if (termParser!=null) termParser.parseConcept(c);
String res=send("(individual-instance? "+in+" "+c+")",true);
return parseBoolean(res);
}
/** This method refers to the RACER individual-instance? macro.
* @return boolean true if in is an instance of c in the abox, and false otherwise.
* @param in java.lang.String The individual name.
* @param c java.lang.String The concept term.
* @param abox java.lang.String THe abox name.
* @exception java.io.IOException Thrown when there is a communication problem with the RACE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -