{"id":22643,"date":"2019-11-01T09:41:03","date_gmt":"2019-11-01T09:41:03","guid":{"rendered":"https:\/\/developer.kore.ai\/v8-0\/?p=22643"},"modified":"2021-03-25T17:39:52","modified_gmt":"2021-03-25T17:39:52","slug":"generation-of-ontology","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v8-0\/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 is 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 is 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 suit your needs. It is highly recommended to review and make changes as the Knowledge Graph generated is a suggestion alone.<\/p>\n<p>NOTE: Knowledge Graph Generator is available from v7.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 v3.6. You can download it <a href=\"https:\/\/www.python.org\/downloads\/\">here<\/a>.<\/li>\n<li><strong>Virtual Environment<\/strong>: It is advised to use a 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 set up a virtual environment.<\/li>\n<li>For Windows Developers:\n<ul>\n<li><strong>Microsoft Visual C++<\/strong> Build Tools &#8211; tested with v14.0.<\/li>\n<li>Windows 10 users must install <strong>Windows 10 SDK<\/strong>. You can download it <a href=\"https:\/\/developer.microsoft.com\/en-us\/windows\/downloads\/windows-10-sdk\/\">here<\/a>.<\/li>\n<li>The operating system must be up to date for a seamless installation of requirements. Some libraries like SpiCy (internal dependency) need specific DLLs that 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=\"\/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 save 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>Download the Knowledge Graph Generator from Kore.ai GitHub: <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>Activate the virtual environment: 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 can see the virtual environment name at the start of every command in the console.<\/li>\n<li>Install the requirements: Run the following command from your project root directory (KnowledgeGraphGenerator) in the virtual environment to install the 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 the <em>requirement.txt<\/em> file.<br \/>\n<code>pip list<\/code><\/li>\n<li>Download spacy English model: Run the 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 prerequisites 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 style=\"text-align: center\"><strong>Option<\/strong><\/td>\n<td style=\"text-align: center\"><strong>Description<\/strong><\/td>\n<td style=\"text-align: center\"><strong>Mandatory\/Optional<\/strong><\/td>\n<td style=\"text-align: center\"><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 the 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 the language 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 a 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>The output JSON file is generated and placed under the project root directory with the name <code>ao_output.json<\/code><\/p>\n<p>The output JSON file can directly be imported to Knowledge Graph in the bot. <a href=\"\/docs\/bots\/bot-builder-tool\/knowledge-task\/importing-the-bot-ontology-from-csv-or-json\/#Importing_Ontology\">See here<\/a> for steps to import Knowledge Graph.<\/p>\n<p><strong>NOTE<\/strong>: When you try to import the Knowledge Graph it replaces 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 is 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...","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\/v8-0\/wp-json\/wp\/v2\/posts\/22643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/comments?post=22643"}],"version-history":[{"count":6,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts\/22643\/revisions"}],"predecessor-version":[{"id":26559,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts\/22643\/revisions\/26559"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/media?parent=22643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/categories?post=22643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/tags?post=22643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}