用于连接同义词的 SPARQL 查询?
SPARQL query for concatenating synonyms?
我正在尝试将来自 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 open source,如果它有任何不同的话。
谢谢,@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 |
+-----------------------+-----------------------------------------------------------------------------+-----------------+
我正在尝试将来自 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 open source,如果它有任何不同的话。
谢谢,@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 |
+-----------------------+-----------------------------------------------------------------------------+-----------------+