簡體   English   中英

python OWLReady2本體無法執行代碼獲取拒絕訪問錯誤

[英]python OWLReady2 ontology cannot execute the code getting access denied error

我正在嘗試執行文檔https://owlready2.readthedocs.io/en/latest/reasoning.html中提到的本體代碼。 我還提到了推理部分的 Java 路徑,但我仍然收到訪問被拒絕的錯誤。 因為我是這個領域的初學者,請你幫我看看我哪里出錯了。

代碼:

from owlready2 import *
import owlready2
owlready2.JAVA_EXE = "C:\\Program Files\\Java\\jdk-19\\bin"

from owlready2 import *

onto = get_ontology("http://test.org/onto.owl")

with onto:
    class Drug(Thing):
        def take(self): print("I took a drug")
    class ActivePrinciple(Thing):
         pass

    class has_for_active_principle(Drug >> ActivePrinciple):
         python_name = "active_principles"

    class Placebo(Drug):
        equivalent_to = [Drug & Not(has_for_active_principle.some(ActivePrinciple))]
        def take(self): print("I took a placebo")

    class SingleActivePrincipleDrug(Drug):
        equivalent_to = [Drug & has_for_active_principle.exactly(1, ActivePrinciple)]
        def take(self): print("I took a drug with a single active principle")

    class DrugAssociation(Drug):
        equivalent_to = [Drug & has_for_active_principle.min(2, ActivePrinciple)]
        def take(self): print("I took a drug with %s active principles" % len(self.active_principles))

acetaminophen   = ActivePrinciple("acetaminophen")
amoxicillin     = ActivePrinciple("amoxicillin")
clavulanic_acid = ActivePrinciple("clavulanic_acid")

AllDifferent([acetaminophen, amoxicillin, clavulanic_acid])

drug1 = Drug(active_principles = [acetaminophen])
drug2 = Drug(active_principles = [amoxicillin, clavulanic_acid])
drug3 = Drug(active_principles = [])

close_world(Drug)

sync_reasoner()`

[錯誤圖片]( https://i.stack.imgur.com/bq6OO.png )

不知道為什么我在使用 sync_reasoner() 后出現訪問被拒絕錯誤它必須檢查類的一致性並重新分配但我收到錯誤

owlready2.JAVA_EXE應設置為 Java 可執行文件 ( java.exe ) 的路徑,而不是包含它的目錄。 請參閱 Owlready2 文檔中的配置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM