使用来自 IOT getschema.org JSON 数据将获得“事物”名称

Consuming JSON data from getschema.org IOT get the "thing" name

本文关键字:事物 名称 数据 JSON IOT org getschema      更新时间:2023-09-26

我刚刚进入语义世界,有些事情我无法理解。我正在尝试弄清楚如何根据其上的微数据标签检查哪种元素是 HTML 元素。我正在使用Firefox扩展程序,因此我对请求和低权限的内容没有任何限制。我只需要弄清楚元素是什么,并通过了解架构中定义的"事物"类型,以用户可理解的语言(例如没有MusicRecording)显示警报。请考虑以下微数据示例:

<div itemscope itemtype="http://schema.org/MusicRecording">
  <span itemprop="byArtist" itemscope itemtype="http://schema.org/MusicGroup">
    British rock band 
   <span itemprop="name">Queen</span> 
  </span>
  for their 
  <span itemprop="inAlbum" itemscope itemtype="http://schema.org/MusicAlbum"> 
    <span itemprop="dateCreated">1977</span> album  
    <span itemprop="name">News of the World</span>
  </span>
<div>
通过

读取itemtype,我需要能够检索事物的名称(类似于"音乐录制"),但不分析字符串;以"正确的方式",通过查询某些内容并要求它。问题是,我找不到 REST api 或类似的东西来获取名称,我需要用纯 javascript 来做到这一点。

所以。。。有什么线索/想法吗?(除了询问此类URL的DOM)

Schema.org 词汇表的规范机器可读表示形式在RDFa中: http://schema.org/docs/schema_org_rdfa.html

在此文件中,每个 Schema.org 类型(rdfs:Class)都有一个rdfs:label属性的值,该值"可用于提供资源名称的人类可读版本"。

但是,似乎 Schema.org 团队决定提供与URL中给出的标签一样的标签,因此http://schema.org/MusicRecording它是"音乐录制",而不是"音乐录制":

<div typeof="rdfs:Class" resource="http://schema.org/MusicRecording">
  <span class="h" property="rdfs:label">MusicRecording</span>
  <span property="rdfs:comment">A music recording (track), usually a single song.</span>
   <span>Subclass of: <a property="rdfs:subClassOf" href="http://schema.org/CreativeWork">CreativeWork</a></span>
</div>

我认为RDF翻译应用程序会对你有所帮助。除了UI之外,它还公开了一个REST服务,您可以使用该服务将微数据转换为其他RDF序列化,如turtle等。然后,您将能够使用SPARQL查询该数据。您可以想象到的任何语言都有实现。

或者,可能有一个直接理解微数据的库,但我不确定。