我有一个看起来像这样的数据集
id | sentence | tags
1 | "people walk dogs in the park" | "pet park health"
2 | "I am allergic to dogs" | "allergies health"
是否可以使用 sql 查询找到每个标记词和每个句子词之间的数量共现?这会很困难,因为您必须解析每个标签和句子条目。
它可能看起来像
select sentence_word,tag_word,count(id)
from
(select id,sentence_word
from table)A
join
(select id, tag_word
from table)B
on A.id=B.id
group by sentence_word,tag_word
除了我知道这两个子查询不正确
以下是一些示例结果
tag_word | sentence_word | count(id)
"walk" |"pet" |1
"health" |"dogs" |2
"allergies" |"dogs" |1