7

我是新手,我必须使用曼彻斯特 OWL 语法为具有与 soduku 相似属性的网格建模。

我一直在搜索,但似乎找不到一种方法来制定一个公理,即“每列必须有 4 个单元格,并且必须具有这些值中的每一个”。如,假设一个 4x1 列,每个单元格必须包含一个数字,并且该列必须包含所有数字 [1:4]。

我已经设置了一些 Objects 、 data 属性和 Object 属性,我将在这里留下。我将把完整的 .owl 文件留在这里,以便可以加载它,从而更容易提供帮助。

高度赞赏所有帮助。

Prefix: dc: <http://purl.org/dc/elements/1.1/>
Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix: GridTest: <http://www.semanticweb.org/existance/ontologies/2017/4/GridTest#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>



Ontology: <http://www.semanticweb.org/existance/ontologies/2017/4/GridTest>


Datatype: xsd:int


Datatype: xsd:integer


ObjectProperty: GridTest:hasCell

    SubPropertyOf: 
        GridTest:hasRelation

    Domain: 
        GridTest:Grid

    InverseOf: 
        GridTest:isCellOf


ObjectProperty: GridTest:hasColum

    SubPropertyOf: 
        GridTest:hasRelation

    Domain: 
        GridTest:Grid

    Range: 
        GridTest:Grid

    InverseOf: 
        GridTest:isColumOf


ObjectProperty: GridTest:hasRelation


ObjectProperty: GridTest:isCellOf

    InverseOf: 
        GridTest:hasCell


ObjectProperty: GridTest:isColumOf

    InverseOf: 
        GridTest:hasColum


DataProperty: GridTest:hasValue

    Characteristics: 
        Functional

    Domain: 
        GridTest:Cell

    Range: 
        {"1"^^xsd:int , "2"^^xsd:int , "3"^^xsd:int , "4"^^xsd:int}


Class: GridTest:Cell

    SubClassOf: 
        GridTest:Grid,
        GridTest:hasValue exactly 1 xsd:int


Class: GridTest:Colum

    SubClassOf: 
        GridTest:Grid,
        GridTest:hasCell exactly 4 GridTest:Cell


Class: GridTest:Grid

    SubClassOf: 
        GridTest:hasColum exactly 4 GridTest:Colum


Individual: GridTest:cell1

    Facts:  
     GridTest:isCellOf  GridTest:col,
     GridTest:hasValue  1


Individual: GridTest:cell2

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:cell3

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:cell4

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:col

    Facts:  
     GridTest:isColumOf  GridTest:grid


Individual: GridTest:grid

编辑:这一点是当我运行推理器时,某些单元格的值,它将推断其他单元格的值。例如:cell1 = 1, cell2 =2, cell3 = 3 => 推理器将推断 cell4 的值为 4。

4

1 回答 1

1

通过改变方法,我已经为这个项目和这个问题提出了一个解决方案。与其将单元格作为具有值的类,不如将值视为需要放入单元格中的实体来轻松完成。

使用这种思路,一切都可以归结为轴子中的逻辑表达式。

通过拥有一个 Value 类,一个向个体添加值的数据属性,以及用断言的正确 Data 属性表示该值的个体,可以简单地说,Cell 对象(hasvalue value 1) or (hasValue value 2) ...hasvalue exactly 1 value

于 2017-05-25T23:25:21.940 回答