Menu

knowledge base

kahina
2017-05-27
2019-07-02
  • kahina

    kahina - 2017-05-27

    Hello.
    I created successfully a probabilistic ontology with PR-OWL2 , my problem is that I need to populate the knowledge base .plm using my own interfaces.
    so, I will be so thankful if you can help me by given me tutorials, codes ... which manipulate the knowledge base( insert, update and delete )

    Thank you in advance.

     
    • Shou Matsumoto

      Shou Matsumoto - 2017-05-28

      I'm assuming that you are directly or indirectly using UnBBayes-MEBN's API, thus your ontology is already loaded to the java class unbbayes.prs.mebn.MultiEntityBayesianNetwork (for loading your ontology to an instance of MultiEntityBayesianNetwork, please refer to line 455 of unbbayes.TextModeRunner of UnBBayes-MEBN project/plug-in). Just reminding that you'll need to use unbbayes.io.mebn.UbfIO2 instead of UbfIO to load PR-OWL 2 files, so you can't use TextModeRunner "as-is" for PR-OWL 2 (I'm referencing TextModeRunner just as an example).

      You'll basically need to first populate your instance of unbbayes.prs.mebn.MultiEntityBayesianNetwork with findings and instances of entities (a knowledge base in UnBBayes-MEBN is basically a collection of entity instances and findings), and then use unbbayes.prs.mebn.kb.powerloom.PowerLoomKB to convert such entity instances and findings to a power loom format (i.e. .plm file).

      The following are the typical steps and where to find some code (you may reuse, invoke, or just copy the codes to your program):

      1. Populating unbbayes.prs.mebn.MultiEntityBayesianNetwork with entity instances: see unbbayes.controller.mebn.MEBNController#createEntityIntance to create, MEBNController#removeEntityIntance to delete, and MEBNController#renameEntityIntance to rename.

      2. Creating/adding a finding to some resident node: see MEBNController#createRandomVariableFinding. You may see that a finding is basically a tuple of resident node, value of the resident node, and values of its arguments. See TextModeRunner#callLaskeyAlgorithm for an example of how to retrieve a resident node by its name, retrieve possible values of that resident node, and possible values of its arguments.

      3. Filling a Knowledge Base instance (i.e. preparing to save as plm file): instantiate a unbbayes.prs.mebn.kb.powerloom.PowerLoomKB and see TextModeRunner#createKnowledgeBase for an example of how to populate it.

      4. Saving to a plm file: just invoke PowerLoomKB#saveFindings(File) with the same PowerLoomKB object you used in previous step.

      Another way of doing it (which might be easier if you aren't familiar with UnBBayes-MEBN's API) is to consider that .plm files are text files in power loom KIF-like syntax, so an alternative way to edit/populate the knowledge base is to let your program to write/save a text file and then load it from UnBBayes-MEBN API, like in line 461 of main method of unbbayes.TextModeRunner (of UnBBayes-MEBN project) only for reasoning (i.e. for answering queries).

      You may use the Star Trek's example "KnowledgeBase_Simple_HP_ST4_T1.plm" as your template.
      You can simply repeat the preambles (i.e. copy/reuse everything that does not start with "(assert" ) and only modify the lines starting with "(assert".

      For example, lines like "(ASSERT (STARSHIP_LABEL ST0))" are declaring instances of entities. Namely, it states that "ST0" is an instance of entity "STARSHIP" (UnBBayes-MEBN uses the "_LABEL" suffix to indicate "type" of some entity). You can write lines similar to these in your plm file in order to declare your instances/types in your knowledge base.

      Lines like "(ASSERT (= (STARSHIPZONE ST4) Z0))" are for declaring findings. This one is inserting a finding that forces the value of node STARSHIPZONE(ST4) to be Z0.
      Similarly, "(ASSERT (not (ISOWNSTARSHIP ST4)))" is inserting a boolean finding indicating that the boolean node ISOWNSTARSHIP(ST4) is false. You can write lines similar to these in order to declare your own findings.

      Please, notice that Powerloom KIF uses prefixed notation, so operators always come before the operands/arguments.

      Again, once your program writes your own .plm file, you can load it and use it just like in the main method of unbbayes.TextModeRunner class of UnBBayes-MEBN project for reasoning.

      Best regards.

      P.S. If you are using PR-OWL 2, you may optionally use unbbayes.prs.mebn.kb.extension.ontology.protege.PROWL2KnowledgeBase instead of unbbayes.prs.mebn.kb.powerloom.PowerLoomKB (.plm files) in order to load your knowledge base from a .owl file in OWL direct semantics (i.e. OWL-DL) instead of loading from PLM files.
      Since PR-OWL 2 files are also .owl files compatible with OWL direct semantics, this class allows you to, for example, load your MTheory (MEBN model) from a PR-OWL 2 file and then load the knowledge base from the same file (i.e. it gives you the option of having the Knowledge Base and the MTheory in the same OWL file). Of course you can also specify 2 different OWL files if you want the Knowledge Base to be some OWL file but not the same file of the MTheory.

       
  • kahina

    kahina - 2017-06-29

    Thank you,
    but i'm still having a difficulty,so if there's a chance for you to give me an example.
    Thank you in advance.

     
  • kahina

    kahina - 2017-08-28

    Hi,
    i still don't know how to update my Knowledge Base, can u please help me, Thank you in advance.
    Regards

     
  • kahina

    kahina - 2017-08-28
     

    Last edit: kahina 2017-08-28
  • Zach Nudelman

    Zach Nudelman - 2019-06-28

    Hi there,

    I have attempted to populate a knowledge base using my owl file. However, after calling loadKnowledgeBase(ubfFile, true), I am unable to load the MultiEntityBayesianNetwork. Specifically, (according to the PROWL2TextModeRunner file)
    1. I have loaded it into memory using myMEBN.owl.
    2. I then initialize a PROWL2KnowledgeBase with the static buildKB() method.
    3. I use TextModeRunner.createKnowledgeBase
    At this point my MEBN is not null.
    4. I call loadModule()
    At this point, my MEBN has become null.

    I tried to look at the loadModule method and have narrowed the point at which the mebn becomes null to the method knowledgeBase.getOWLModelManager().getOWLReasonerManager().

    Even if I try construct a new mebnIO object and MultiEntityBayesianNetwork object, it is null after I load the MEBN from the .owl file.

    If anyone knows why this is happening or how I can fix it I will appreciate it greatly!

    Regards,
    Zach

     
    • Zach Nudelman

      Zach Nudelman - 2019-06-28

      Root of my problem came from not following the instructions in this thread which references another important one. To do with reading in owl files and protege libs

       
      • Zach Nudelman

        Zach Nudelman - 2019-07-02

        I would like to know if it's possible to load in a mebn without the protege gui opening as I feel this would positively affect run time of the program. So if anyone knows load a PROWL2 file without using Protege41CompatiblePROWL2IO, please do let me know.

        When trying to use the OWLAPI equivalent IO, I get a null exception when trying to load the knowledge base. The PROWL2TextRunner gives an exception at the same point.

         

Log in to post a comment.