haipv1108 / androjena

Automatically exported from code.google.com/p/androjena
0 stars 0 forks source link

issue about owl inference #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.To put ".owl" and ".rule" files in assets folder, then read by inputstream.
2.Reasoning by GenericRuleReasoner and ModelFactory.createInfModel(reasoner, 
ontologyModel);

What is the expected output? What do you see instead?
1.Expected: The inference results.
2.I see: 
error in this line
InfModel inf = ModelFactory.createInfModel(reasoner, om);//error
3.Error Message: application has stopped unexpectedly. please try again.

If you're using a real device and not the emulated AVD, what is the device
model?
No, I just use the AVD.
Target Name:Android 2.3.3
Ram: 800mb
VM Heap: 512mb
Internal Storage: 512mb
SD card: 512mb

What version of Android runs on your device/emulated AVD? (please put an X
next to the correct version)
Android 2.3.3 (Gingerbread)

What version of Android is your application targeting? (please put an X
next to the correct version)
Android 2.3.3 (Gingerbread)

What IDE/environment are you developing with? (Eclipse w/ ADT, Android SDK
w/ Apache Ant, ...)
Eclipse 4.2.1,
Android SDK r21.0.1

What operating system and hardware is your IDE/development environment
running on?
Win7 x64
CPU:i5-3210M 2.5GHz
RAM:8GB

Please attach the following application files (when applicable):

- AndroidManifest.xml
- .classpath
- default.properties
- a full LogCat dump from application launch to exception/crash
- a meaningful portion of the source code where the exception is thrown

Please provide any additional detail below
------------------The Inference Code.------------------
I just want read the .owl file and .rules File, and reasoning by rules.
I already test the results with Jena and Java, it work successfully.

The error line: InfModel inf = ModelFactory.createInfModel(reasoner, om);
I think maybe the error caused by List<Rule>, the rule format.
However, I am not sure how to use AndroidJena with android for reasoning.
the following annotation just for testing the results.

public void InferenceRelation(Resource a, Resource b, Property p) 
{
    Model model = ModelFactory.createDefaultModel();
    TextView textv01 = (TextView)findViewById(R.id.textView1);
    TextView textv02 = (TextView)findViewById(R.id.textView2);

        try {
    InputStream in = getAssets().open("first.owl");
    model.read(in, null);
        InputStream in2 = getAssets().open("first_rules.rules");
    BufferedReader reader = new BufferedReader(new  InputStreamReader(in2,"Big5"));

    String s = "";
    String s2 = "";                 

    List Rules = new ArrayList();               
    while((s=reader.readLine())!=null){      
    s2 +=s;  //1    print inputstream success!! 
    Rules.add(s);
    }
    //textv02.setText(s2); //1  

    GenericRuleReasoner reasoner = new  GenericRuleReasoner((List<Rule>)Rules);
    //GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule.parseRules(s2));//it can't work
    //textv02.setText((String)Rules.get(0)); //print List

    reasoner.setOWLTranslation(true);
    reasoner.setDerivationLogging(true);
    reasoner.setTransitiveClosureCaching(true);

    OntModel om = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF,model);

        Resource configuration = om.createResource();
            configuration.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");

            InfModel inf = ModelFactory.createInfModel(reasoner, om);  // Error in this Line!!

  } 
  catch (IOException e) 
  {
    textv01.setText(e.getMessage());
    e.printStackTrace();            
  }

Please help me,
If necessary, I can attach the total file.
Thank you very much.

Original issue reported on code.google.com by pkjr8...@gmail.com on 2 Feb 2013 at 2:38

Attachments:

GoogleCodeExporter commented 8 years ago
Well,
I already address the problem.
The problem is as mentioned before, List<Rule>.
I can only use String "rule" for reasoning,
for example, String s2 = "rule...";
then the following work successful.
GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule.parseRules(s2));
However, I found two things.
1. I can't use prefix in rule syntax
for example,
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix relate: <http://www.owl-ontologies.com/Ontology1300690296.owl#>.
so I must use the full path in rule syntx. 

2. I want use multi-rules, but the inference seems just only reason 1 rule.
for example, 
String s2 = "[rule1:(?a rdf:type ?b)(?b rdf:type ?c)->(?a rdf:type ?c)]"; // it 
shows result.
s2 += "[rule2:(?a rdf:type ?c)(?c rdf:type ?d)->(?a rdf:type ?d)]";//it don't 
show any results.
Alouth
That seems little different with Jena support, does there has simple solution?
such as just read .rule file and reasoning.
Thank you very much.

Original comment by pkjr8...@gmail.com on 3 Feb 2013 at 1:39

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Oh... I am sorry for that...
I misunderstand.. it's my display problems,
Now I can reasoning by multi-rules.

Original comment by pkjr8...@gmail.com on 3 Feb 2013 at 1:59

GoogleCodeExporter commented 8 years ago
So you solved the issue by yourself? Can I close this?

Original comment by loreca...@gmail.com on 3 Feb 2013 at 3:13

GoogleCodeExporter commented 8 years ago
ok, no problem thanks.

Original comment by pkjr8...@gmail.com on 3 Feb 2013 at 11:12

GoogleCodeExporter commented 8 years ago

Original comment by loreca...@gmail.com on 3 Feb 2013 at 11:20