{"id":22643,"date":"2019-11-01T09:41:03","date_gmt":"2019-11-01T09:41:03","guid":{"rendered":"https:\/\/developer.kore.ai\/v7-3\/?p=22643"},"modified":"2020-07-30T04:58:23","modified_gmt":"2020-07-30T03:58:23","slug":"generation-of-ontology","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-3\/docs\/bots\/bot-builder-tool\/knowledge-task\/generation-of-ontology\/","title":{"rendered":"Generation of Knowledge Graph"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>The performance of Kore.ai\u2019s Knowledge Graph is based on the proper organization of the Knowledge Graph based upon key domain terms and establishing a hierarchy.<\/p>\n<p>Building the FAQs might be easy when you start fresh with the Knowledge Graph, but in case you have a list of questions-answer pairs converting the same into a fully functional Knowledge Graph might be a tedious task.<\/p>\n<p>Kore.ai&#8217;s Knowledge Graph Generator automatically extracts terms from FAQs, defines the hierarchy between these terms, and also associates the FAQs to the right terms. You can then import the output file from the generator to your Bot\u2019s Knowledge Graph, without having to worry about the hierarchy. You can also edit the hierarchy, after import, to suite your needs. It is highly recommended you review and make changes as the Knowledge Graph generated is a suggestion alone.<\/p>\n<p>NOTE: Knowledge Graph Generator is available from ver7.1 of the platform.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>The Kore.ai Knowledge Graph Generator is hosted on the Kore GitHub repository. This document gives the steps in the installation and usage of the generator.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Prerequisites\">Prerequisites<\/span><\/h2>\n<ul>\n<li><strong>Python 3.6<\/strong>: The Knowledge Graph Generator requires python 3.6. This can be downloaded from <a href=\"https:\/\/www.python.org\/downloads\/\">here<\/a>.<\/li>\n<li><strong>Virtual Environment<\/strong>: It is advised to use virtual environment, instead of installing requirements in the system directly. Follow the <a href=\"https:\/\/docs.python.org\/3\/tutorial\/venv.html#creating-virtual-environments\" target=\"_blank\" rel=\"noopener noreferrer\">steps mentioned here<\/a> to setup virtual environment.<\/li>\n<li>For <span style=\"text-decoration: underline\">Windows developers<\/span>:\n<ul>\n<li><strong>Microsoft Visual C++<\/strong> Build Tools &#8211; tested with ver 14.0<\/li>\n<li>Windows 10 users should install <strong>Windows 10 SDK<\/strong>. You can download it from <a href=\"https:\/\/developer.microsoft.com\/en-us\/windows\/downloads\/windows-10-sdk\/\">here<\/a>.<\/li>\n<li>Operating system should be upto date for seamless installation of requirements. Some libraries like SpiCy (internal dependency) need specific DLLs which are available in the latest updates.<\/li>\n<\/ul>\n<\/li>\n<li>A file containing the FAQs in <em>json<\/em> or <em>csv<\/em> format. You can obtain this file in two ways:\n<ul>\n<li>Export the Knowledge Graph from Kore.ai Bot Builder platform, <a href=\"\/v7-3\/docs\/bots\/bot-builder-tool\/knowledge-task\/importing-the-bot-ontology-from-csv-or-json\/#Exporting_Ontology\">see here for how<\/a>.<\/li>\n<li>Build the Knowledge Graph in a tabular form, with questions in the first column and answers in the corresponding second column and saving the file in <em>csv<\/em> format.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Configuration\">Configuration<\/span><\/h2>\n<ol>\n<li><strong>Download the KnowledgeGraphGenerator from Kore.ai GitHub<\/strong>: <a href=\"https:\/\/github.com\/Koredotcom\/KnowledgeGraphGenerator\">https:\/\/github.com\/Koredotcom\/KnowledgeGraphGenerator<\/a>.<\/li>\n<li>Extract the zip file into a folder and open the command prompt from that generator folder.<\/li>\n<li><strong>Activate virtual environment<\/strong>: Execute the following command replacing the placeholders with actual values to activate the virtual environment:\n<ul>\n<li>For windows:<br \/>\n<code>&lt;virtual_environments_folder_location&gt;\/&lt;virtualenv_name&gt;\/Scripts\/activate<\/code><\/li>\n<li>For Unix\/MacOS:<br \/>\n<code>&lt;virtual_environments_folder_location&gt;\/&lt;virtualenv_name&gt;\/bin\/activate<\/code>.<\/li>\n<\/ul>\n<p>Once the virtual environment is activated, you should see the virtual environment name at the start of every command in the console.<\/li>\n<li><strong>Install the requirements<\/strong>: Run the following command from your project root directory (KnowledgeGraphGenerator) in the virtual environment to install requirements<br \/>\n<code>pip install -r requirements.txt<\/code><br \/>\nYou can verify the installation by running the following command and ensuring that the list contains all the components mentioned in <em>requirement.txt<\/em> file.<br \/>\n<code>pip list<\/code><\/li>\n<li><strong>Download spacy english model<\/strong>: Run following command to download spaCy, the NLP model.<br \/>\n<code>python -m spacy download en<\/code><\/li>\n<\/ol>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Execution\">Execution<\/span><\/h2>\n<p>Now that you have the pre-requisites and have configured the Knowledge Graph Generator, let us see how to generate the Knowledge Graph.<\/p>\n<p>The following command executes the generator:<\/p>\n<p><code>python KnowledgeGraphGenerator.py --file_path &lt;INPUT_FILE_PATH&gt; --type &lt;INPUT_FILE_TYPE&gt; --language &lt;LANGUAGE_CODE&gt; --v &lt;true\/false&gt;<\/code><\/p>\n<p>Let us look at each of the options:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Option<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<td><strong>Mandatory\/Optional<\/strong><\/td>\n<td><strong>Default Value<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Input File Path<\/td>\n<td>Input file name along with the location<\/td>\n<td>Mandatory<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Input File Type<\/td>\n<td>The type of input file:<\/p>\n<ul>\n<li><em>json_export<\/em> &#8211; for files exported from Kore.ai Bot Builder using JSON Export option<\/li>\n<li><em>csv_export<\/em> &#8211; for files exported from Kore.ai Bot Builder using CSV Export option<\/li>\n<li><em>csv<\/em> &#8211; for files with questions in first column and answers in the respective second column<\/li>\n<\/ul>\n<\/td>\n<td>Mandatory<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Language Code<\/td>\n<td>The language code for langauge in which input data exist<\/td>\n<td>Optional<\/td>\n<td>en (English)<\/td>\n<\/tr>\n<tr>\n<td>Verbose Mode<\/td>\n<td>Running command in verbose mode to see intermediate progress steps<\/td>\n<td>Optional<\/td>\n<td>false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Output\">Output<\/span><\/h2>\n<p>Output JSON file is generated and placed under project root directory with name <code>ao_output.json<\/code><\/p>\n<p>The output JSON file can directly be imported to Knowledge Graph in Bot. <a href=\"\/v7-3\/docs\/bots\/bot-builder-tool\/knowledge-task\/importing-the-bot-ontology-from-csv-or-json\/#Importing_Ontology\">See here<\/a> for steps in Importing Knowledge Graph.<\/p>\n<p><strong>NOTE<\/strong>: When you try to import the Knowledge Graph it will replace the existing one. We recommend you take a back up before importing.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"The performance of Kore.ai\u2019s Knowledge Graph is based on the proper organization of the Knowledge Graph based upon key domain terms and establishing a hierarchy. Building the FAQs might be easy when you start fresh with the Knowledge Graph, but in case you have a list of questions-answer pairs converting the same into a fully...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-22643","post","type-post","status-publish","format-standard","hentry","category-knowledge-task"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/posts\/22643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/comments?post=22643"}],"version-history":[{"count":3,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/posts\/22643\/revisions"}],"predecessor-version":[{"id":24150,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/posts\/22643\/revisions\/24150"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/media?parent=22643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/categories?post=22643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-3\/wp-json\/wp\/v2\/tags?post=22643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}