-1

我的 RDF:

<rdf:Description rdf:about="http://earthquake.linkeddata.it/resource/Isolator">
  <owl:equivalentClass rdf:resource="http://earthquake.linkeddata.it/resource/VibrationAbsorber"/>
  <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>

<rdf:Description rdf:about="http://earthquake.linkeddata.it/resource/MagnetoRheological(MR)damper">
  <owl:equivalentClass rdf:resource="http://earthquake.linkeddata.it/resource/**SemiActiveDamper**"/>
  <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>

我的代码:

public static void main (String args[]) throws IOException,InterruptedException {

// create an empty model
 OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,null);

// use the class loader to find the input file
InputStream in = FileManager.get().open(inputFileName);
if (in == null) {
    throw new IllegalArgumentException( "File: " + inputFileName + " not found");
}

// read the RDF/XML files
m.read( in, "" );

Scanner user_input=new Scanner(System.in);
String input;
System.out.print("Enter your concept");
input= user_input.next();

ExtendedIterator<?> i1 = m.listClasses();
while(i1.hasNext()){
 OntClass oc = (OntClass)i1.next();

 if( oc.getEquivalentClass() != null){
   input=oc.getEquivalentClass().toString();
 System.out.println("Equivalent Class name: "+oc.getEquivalentClass().getLocalName());
  }
}

使用这段代码,我得到了一个等价类的列表,例如 SemiActiveDamper 和 VibrationAbsorber。但我的目标只是根据用户输入获得 SemiActiveDamper 或 VibrationAbsorber。我该如何解决这个问题?

4

1 回答 1

2

http://answers.semanticweb.com/questions/24208/how-to-get-equivalent-class-depends-on-user-input的副本

对等价类的 URi 使用字符串比较

更好 - 将用户可读的标签添加到类并搜索它们。

于 2013-08-26T14:41:04.693 回答