【问题标题】:SPARQL query for concatenating synonyms?用于连接同义词的 SPARQL 查询?
【发布时间】:2015-10-07 15:44:51
【问题描述】:

我正在尝试将来自 RDF 源的数据转换为 @note2 biomedical text mining application 期望的字典格式

具体来说,我正在尝试将一个概念的所有同义词合并到一行中

@note2 使用dictionaries in this format

+----------+-----------+---------------+-------------------------+
|  class   |   term    |   synonyms    |      external IDs       |
+----------+-----------+---------------+-------------------------+
| food     | bread     | pan|brot      | source1;idA             |
| nutrient | vitamin C | ascorbic acid | source1;idC|source2;idD |
+----------+-----------+---------------+-------------------------+

我可以在bioportal这样的查询中获得每行一个同义词

SELECT ?term ?syn ?extid
FROM <http://bioportal.bioontology.org/ontologies/BTO>
WHERE
{
  ?extid <http://bioportal.bioontology.org/metadata/def/prefLabel> ?term .
  ?extid <http://www.geneontology.org/formats/oboInOWL#hasRelatedSynonym> ?syn .
}

返回类似这样的内容:

+-------------------------+-------------------------+-----------------+
|          term           |           syn           |      extid      |
+-------------------------+-------------------------+-----------------+
| "stomach smooth muscle" | "gastric muscle"        | bto:BTO_0001818 |
| "stomach smooth muscle" | "gastric smooth muscle" | bto:BTO_0001818 |
| "stomach smooth muscle" | "stomach muscle"        | bto:BTO_0001818 |
+-------------------------+-------------------------+-----------------+

那么...是否有可能在 SPARQL 中连接同义词并最终得到类似的东西

+-----------------------+----------------------------------------------------------------------------+-----------------+
|         term          |                                    syn                                     |      extid      |
+-----------------------+----------------------------------------------------------------------------+-----------------+
| stomach smooth muscle | gastric muscle|gastric smooth muscle|stomach smooth muscle |stomach muscle | bto:BTO_0001818 |
+-----------------------+----------------------------------------------------------------------------+-----------------+

如果有什么不同,我将使用 virtuoso 开源。

【问题讨论】:

  • 我还没有尝试过,但是“group_concat”看起来很有希望:stackoverflow.com/a/18214142/4154134
  • @jdussault 看起来很有希望。你想提交答案,还是我应该提交我对你的建议能做的事情?
  • 去做吧!我有兴趣看看它长什么样。 :)

标签: rdf sparql bioinformatics


【解决方案1】:

谢谢,@jdussault!

SELECT ?term (group_concat(distinct ?syn ; separator = "|") AS ?synset) ?extid
FROM <http://bioportal.bioontology.org/ontologies/BTO>
WHERE
{
  ?extid <http://bioportal.bioontology.org/metadata/def/prefLabel> ?term .
  ?extid <http://www.geneontology.org/formats/oboInOWL#hasRelatedSynonym> ?syn .
}
group by ?term

.

+-----------------------+-----------------------------------------------------------------------------+-----------------+
|         term          |                                   synset                                    |      extid      |
+-----------------------+-----------------------------------------------------------------------------+-----------------+
| "3T3-F442A cell"      | "F442A cell|3T3-442A cell"                                                  | bto:BTO_0001169 |
| "stria terminalis"    | "terminal stria|Tarins tenia|tenia semicircularis|Fovilles fasciculus"      | bto:BTO_0004616 |
| "intervertebral disc" | "spinal disk|spinal disc|intervertebral fibrocartilage|intervertebral disk" | bto:BTO_0003625 |
+-----------------------+-----------------------------------------------------------------------------+-----------------+

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多