美文网首页
医疗问答知识图谱

医疗问答知识图谱

作者: 旅行小张 | 来源:发表于2020-06-08 09:08 被阅读0次

    本文数据为在网上爬取的医疗数据,共有四列,分别是,一级科室,二级科室,问题,回答

    创建一级科室节点

     创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row

    merge (ADepartment:ADepartment {ADepartmentName:row.一级科室});

    查询语句:

    match (a:ADepartment) 

    return a;  

    如果出现以下错误,可能是单元格中是中文,而该csv文件的编码格式不是UTF-8,将文件编码格式改为UTF-8后,导入节点成功。

    修改文件编码格式:将csv文件用txt打开,文件--->另存为--->编码格式

    错误提示

    创建二级科室节点

    创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row

    merge (BDepartment:BDepartment {BDepartmentName:row.二级科室})

    查询语句:

    match (b:BDepartment) 

    return b;  

    创建一级科室和二级科室的包含关系

    创建语句:

    load csv with headers from "file:///有问必答QA.csv" as row

    match (ADepartment:ADepartment {ADepartmentName:row.一级科室})

    match (BDepartment:BDepartment {BDepartmentName:row.二级科室})

    merge (ADepartment)-[:包含]->(BDepartment);

    查询语句:

    match (a:ADepartment)-[r:包含]->(b:BDepartment) 

    return a,r,b;

    创建问题节点

    创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row 

    merge (question:question {question: row.问题})

    查询语句:

    match (q:question) 

    return q

    创建答案节点

    创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row 

    merge (answer:answer {answer:row.回答})

    创建问题和答案的被回答关系

    创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row 

    match (question:question {question:row.问题}) 

    match (answer:answer {answer:row.回答}) 

    merge (question)-[:被回答]->(answer);   

    查询语句:

    match (q:question)-[r:`被回答`]->(a:answer) 

    return q,r,a limit 6

    创建问题和二级科室的关系

    创建语句:

    load csv with headers from 'file:///有问必答QA.csv' as row 

    match (question:question {question:row.问题}) 

    match (BDepartment:BDepartment {BDepartmentName:row.二级科室})

    merge (BDepartment)-[:关联]->(question);  

    查询语句:

    match (b:BDepartment)-[r:`关联`]->(q:question) 

    return b,r,q limit 20

    创建索引

    为确保优化查找,我们将为每一个在查询中会用到的节点属性创建索引,索引通常用唯一值创建,如ID

    创建一级科室名字索引

    create index A_index for (ADepartment:ADepartment) on (ADepartment.ADepartmentName); 

    创建二级科室名字索引

    create index B_index for (BDepartment:BDepartment) on (BDepartment.BDepartmentName);

    创建问题名字索引

    create index q_index for (question:question) on (question.question);

    创建答案名字索引

    create index a_index for (answer:answer) on (answer.answer);

    删除索引

    drop index on:question(question);

    drop index on:answer(answer);

    相关文章

      网友评论

          本文标题:医疗问答知识图谱

          本文链接:https://www.haomeiwen.com/subject/dctazhtx.html