Domain Knowledge Graph-Chinese Recipe Knowledge Graph: Realize Knowledge Graph Visualization and Knowledge Base Intelligent Question Answering System (KBQA)

insert image description here

Project design collection (artificial intelligence direction): Help newcomers quickly master skills in actual combat, complete project design upgrades independently, and improve their own hard power (not limited to NLP, knowledge graph, computer vision, etc.): Collect meaningful project design collections to help Newcomers quickly master skills in actual combat, helping users make better use of the CSDN platform, independently complete project design upgrades, and improve their own hard power.

insert image description here

  1. Column Subscription: Encyclopedia of Projects to Improve Your Hard Power

  2. [Detailed introduction of the column: project design collection (artificial intelligence direction): help newcomers quickly master skills in actual combat, complete project design upgrades independently, and improve their own hard power (not limited to NLP, knowledge graphs, computer vision, etc.)

Domain Knowledge Graph-Chinese Recipe Knowledge Graph: Realize Knowledge Graph Visualization and Knowledge Base Intelligent Question Answering System (KBQA)

A knowledge graph for Chinese cookbook (Chinese recipe knowledge graph), which can realize knowledge graph visualization and knowledge base intelligent question answering system (KBQA)

Show results:

The name of the system developed by this project is AI Food Time , and the Chinese name is爱食光. If you want to experience the visualization function, you can directly access the click visualization function .
By collecting completely open data about Chinese recipes on the Internet, after data cleaning and analysis , it is converted into a knowledge map storage structure , and provides functions such as visual display, search and intelligent question and answer , providing convenient and fast Chinese recipes for people who love food and cooking. Recipe service, which visually displays the relationship between different dishes and the raw materials used in the form of a knowledge graph, has great practical application requirements in life, including:

  • Different specific methods of one type of dish, for example, boiled fish includes spicy boiled fish, small and refreshing version of boiled fish, and home-cooked version of boiled fish, etc.;
  • Through the relationship between dishes and ingredients, you can check which dishes can be cooked with existing ingredients at home;
  • It can directly display the main ingredients, auxiliary ingredients, ingredients and their specific quantities and cooking methods required for each dish, which is simpler and more intuitive than some recipe pages on the Internet;
  • Visualization can have a global understanding of various dishes and their associations, and can display the corresponding pictures of each dish;
  • The intelligent question answering system can use natural language to ask questions, and the system feedbacks the answer results.

See the top or end of the article for the project code source link

https://download.csdn.net/download/sinat_39620217/87988871

1. Visual display and search:

The same type of entities are represented by nodes of the same color. When the mouse is over a certain node, it displays the names of other entities associated with it and the relationship between them; it has the same
type of entity display switch, node display mode conversion, and supports search functions;
each The image of the finished product corresponding to the dish is displayed in the information column of the dish, and entities_aglin.py is used for entity alignment to eliminate redundant information in the food raw materials.

  • Mini version: Contains 10 categories and the relationship between 50 dishes, including various ingredients and production steps for making dishes. The lightweight mini version supports both computer and mobile browsers. If you want to experience it, you can directly enter it access entrance .
  • Pro version (under development): Contains 362 categories, relationships between more than 8,000 dishes, including various raw materials and production steps for making dishes.

2. Intelligent Question Answering System (KBQA):

Based on the constructed Chinese recipe knowledge map, a knowledge base question answering KBQA system is designed. According to the questions raised about the dishes, the system automatically gives answers, and the system can also respond to situations where no answers can be given.

  • folder structure
    • /data: contains triples data aifoodtime_ntriples.nt
    • /external_dict: Entities list entities_list.txt containing all dishes and ingredients
    • query_main.py: KBQA main function
    • jena_sparql_endpoint.py: start the jena_sparql service
    • question2sparql.py: Conversion of natural language questions to SPARQL queries
    • question_temp.py: natural language to SPARQL question template
    • vizdata2entities.py: Conversion from vizstore data to entity list files
    • word_tagging.py: Chinese word segmentation, using jieba

Based on the constructed Chinese recipe knowledge map, the intelligent question answering system can give answers to various questions related to the dishes.
The intelligent question-answering robot in this project is called Snack .
To use this system, pre-installed software is required:

  • Apache Jena Fuseki: Jena Fuseki is a SPARQL service that provides RESTful SPARQL HTTP updates, SPARQL queries, and SPARQL updates using the SPARQL protocol over HTTP.
    Download the latest version of the fuseki compressed package from the official website , and extract it to the target folder. Enter the command on the command line under the target folder of apache-jena-fuseki java -jar fuseki-server.jarto start the Fuseki service. Next, open the browser, visit: http://localhost:3030 , create a persistent database, and upload the /data/aifoodtime_ntriples.nt triples dataset to complete the preparation of the knowledge base.
  • JAVA: The java environment is required to run fuseki. If you have not installed JAVA8.0 or above, please go to the oracle official website to download the latest version of JDK and install it, and configure the environment path.
    The process of the system is: analyze the input natural language questions to generate SPARQL queries, further request the Apache Jena Fuseki service based on the TDB knowledge base in the background, and get the answers. If there is no answer to the question in the knowledge base or if the natural language question raised cannot be understood, the system will also give a corresponding reply.

2.1 Types of questions that can be asked:

  1. The specific dishes contained in a certain type of dish;
  2. All the raw materials of a certain special dish;
  3. The main ingredients, auxiliary materials and ingredients of a certain special dish;
  4. The characteristics of a certain special dish;
  5. A certain special dish production steps.

2.2 How to use:

In the case that the Fuseki service has been started, enter the command line python query_main.pyto start the question answering system and start the question answering process:

cd KBQA
python query_main.py

Question and answer example 1:

请提问:
水煮鱼类包括哪些菜?

小吃:
家常水煮鱼、小清新版水煮鱼、水煮鱼、香辣水煮鱼、麻辣水煮鱼

Question and answer example 2:

请提问:
如何制作水煮鱼?

小吃:
1: 准备食材。2: 将鱼清洗干净后切片,鱼骨和鱼肉分开放。黄豆芽去掉须根、辣椒剪成段、姜切片。接下来开始腌鱼。鱼骨中放入三四片姜、一勺料酒、半勺盐腌制二十分钟。鱼片中放入半只蛋清、一勺料酒、一勺淀粉、一小勺白胡椒粉后抓匀腌制二十分钟。 3: 锅中加适量清水,水烧开后将黄豆芽放入锅中,再放少许盐。待黄豆芽煮熟捞出放入大碗内。4: 锅中倒入少许油,油热后放入一勺郫县豆瓣酱和姜片煸炒出红油(喜欢更辣一点口感的,可以往锅里再放一些干辣椒煸炒出香味)。5: 往锅里倒入适量的热水。6: 将鱼骨放入锅内,大火烧开后转小火炖10分钟。(这个时候可以尝一下鱼汤的味道,然后根据自己的口味选择要不要放盐)鱼骨炖好后捞到装有黄豆芽的大碗中。7: 将鱼肉一片一片的放入锅中。(千万不要搅动,如需要,只要轻轻晃动几下锅即可)8: 煮开后立即将鱼肉捞出,再盛一些汤到碗中。9: 换一只干净的锅中,锅中倒入40毫升左右的食用油,然后将干辣椒和花椒放入锅中,小火煸炒至辣椒红亮,花椒出香味即可捞出放到鱼肉上。10: 将锅中剩下的油大火烧至稍稍冒烟,然后关火,把油淋在鱼肉上即可。

Question and answer example 3:

请提问:
鱼香肉丝的特点是什么?

小吃:
难度: 简单、耗时: 二十分钟、口味: 鱼香、工艺: 炒

Question and answer example 4:

请提问:
山楂红烧肉的主料具体都是哪些啊?

小吃:
香叶: 3片、五花肉: 400克、八角: 2个、冰糖: 20克、姜: 8克、山楂: 200克、桂皮: 4克、花椒: 20颗

Question and answer example 5:

请提问:
可乐鸡翅需要哪些食材?

小吃:
料酒、姜、葱、八角、可乐、鸡翅中

Q&A example 6:

请提问:
水煮肉片的辅料是什么?

小吃:
油菜: 适量、绿豆芽: 适量、金针菇: 适量

Q&A Example 7:

请提问:
今天天气如何?

小吃:
这个问题我真是无法回答。

See the top or end of the article for the project code source link

https://download.csdn.net/download/sinat_39620217/87988871

Guess you like

Origin blog.csdn.net/sinat_39620217/article/details/131641136