使用类别匹配查找两个实体之间的接近度

时间:2015-02-05 05:42:13

标签: sparql semantic-web ontology dbpedia

所有查询都在sparql virtuso端点上进行测试
我想找到两个dbpedia主题的类别,例如 Bharatiya_Janata_Party和New_Delhi。
我想匹配这些类别彼此相似的方式。 < / p>

在第一个查询中,我得到了Bharatiya_Janata_Party的类别。

在第二个查询中,我得到了New_Delhi的类别。

现在我想将Bharatiya_Janata_Party的类别结果与New_Delhi的结果相匹配。喜欢这里

  1. Nationalist_parties --- New_Delhi
  2. Nationalist_parties --- New_Delhi_district
  3. Nationalist_parties --- Populated_places_established_in_1911
  4. Nationalist_parties --- Capitals_in_Asia
  5. Nationalist_parties --- Capitals_in_Asia
  6. Nationalist_parties - Planned_capitals
  7. Political_parties_established_in_1980 --- New_Delhi
  8. Political_parties_established_in_1980 --- New_Delhi_district
  9. .....
  10. .... .. ..
  11. 我已经解雇了一个查询III,用于在 Nationalist_parties --- New_Delhi 之间进行匹配。我得到了第4级的比赛((^ skos:wide){0,4})。

    同样,我必须为Nationalist_parties --- New_Delhi_district做。

    真正的问题是我想要将这3个查询组合在一起,以便我可以以表格形式获得直接结果。有没有办法让整个过程自动化。

    查询I:

     SELECT *
        WHERE {
          dbpedia:Bharatiya_Janata_Party dcterms:subject ?x
        }
    

    查询结果I:

    dbpedia.org/resource/Category:Nationalist_parties
    dbpedia.org/resource/Category:Political_parties_established_in_1980
    dbpedia.org/resource/Category:Conservative_parties_in_India
    dbpedia.org/resource/Category:Hindu_political_parties
    dbpedia.org/resource/Category:Hindutva
    dbpedia.org/resource/Category:Bharatiya_Janata_Party
    dbpedia.org/resource/Category:1980_establishments_in_India
    

    查询II:

    SELECT *
    WHERE {
      dbpedia:New_Delhi dcterms:subject ?x
    }
    

    查询II的结果:

    dbpedia.org/resource/Category:New_Delhi
    dbpedia.org/resource/Category:New_Delhi_district
    dbpedia.org/resource/Category:Populated_places_established_in_1911
    dbpedia.org/resource/Category:Capitals_in_Asia
    dbpedia.org/resource/Category:Indian_capital_cities
    dbpedia.org/resource/Category:Planned_capitals
    dbpedia.org/resource/Category:Urdu-speaking_countries_and_territories
    

    QUERY III:

    select distinct ?super where {
      ?super (^skos:broader){0,4} category:Nationalist_parties, category:New_Delhi
    }
    

    结果:

    dbpedia.org/resource/Category:Government-related_organizations
    dbpedia.org/resource/Category:Government
    

    第4级首次比赛,2个超级课程

    P.S:其他查询不必匹配(^ skos:wider){0,4}。所以我从(^ skos:wider){0,0}手动触发上述查询并递增为(^ skos:wider){0,1} - &gt;(^ skos:wider){0,2} ..到第一场比赛。

    select distinct ?super where {
      ?super (^skos:broader){0,6} category:Nationalist_parties, category:New_Delhi_district
    }
    

    结果:

    dbpedia.org/resource/Category:Categories_by_topic
    dbpedia.org/resource/Category:Government
    dbpedia.org/resource/Category:Categories_by_parameter
    dbpedia.org/resource/Category:Political_geography
    

    第6级首次比赛,4个超级课程

    ===================================

    结合这3个查询,我希望以表格形式提供此类型的结果: -

    ==================================

    ** CategoryI(QueryI ---类别(QuesryII)---级别 - 计数匹配*

    1. Nationalist_parties --- New_Delhi ---------------------------- 4 ------ 2
    2. Nationalist_parties --- New_Delhi_district ------------------- 6 -------- 4
    3. Nationalist_parties --- Populated_places_established_in_1911
    4. Nationalist_parties --- Capitals_in_Asia
    5. Nationalist_parties --- Capitals_in_Asia ...
    6. .....
    7. ....
    8. 请帮我自动化并合并上述查询。我已阅读了几篇文章,但无法弄清楚如何。

0 个答案:

没有答案