-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