{"id":22643,"date":"2019-11-01T09:41:03","date_gmt":"2019-11-01T09:41:03","guid":{"rendered":"https:\/\/developer.kore.ai\/v10-1\/?p=22643"},"modified":"2022-09-22T18:24:35","modified_gmt":"2022-09-22T17:24:35","slug":"generation-of-ontology","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v10-1\/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><span style=\"font-weight: 400\">The performance of the&nbsp; Knowledge Graph is based on proper organization based upon key domain terms, and on establishing a hierarchy.<\/span><\/p>\n<p><span style=\"font-weight: 400\">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 it into a fully functional Knowledge Graph is a tedious task.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Kore.ai&rsquo;s XO Platform provides a Knowledge Graph Generator that 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 VA&rsquo;s 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 only a suggestion.<\/span><\/p>\n<p><strong><em>Note<\/em><\/strong><em><span style=\"font-weight: 400\">: The Knowledge Graph Generator is available from v7.1 of the platform.<\/span><\/em><\/p>\n<p><span style=\"font-weight: 400\">The Kore.ai Knowledge Graph Generator is hosted on the Kore GitHub repository. This document provides the steps needed to install and use the generator.<\/span><\/p>\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>\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 XO 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<th style=\"text-align: center\"><strong>Option<\/strong><\/th>\n<th style=\"text-align: center\"><strong>Description<\/strong><\/th>\n<th style=\"text-align: center\"><strong>Mandatory\/Optional<\/strong><\/th>\n<th style=\"text-align: center\"><strong>Default Value<\/strong><\/th>\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<table style=\"background-color: #fffbea;width: 100%\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\"><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.<br \/>\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><\/div><\/div><\/div><\/div><\/div><\/section><\/td>\n","protected":false},"excerpt":{"rendered":"The performance of the&nbsp; Knowledge Graph is based on proper organization based upon key domain terms, and on 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 it into a fully functional Knowledge Graph is a tedious...","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\/v10-1\/wp-json\/wp\/v2\/posts\/22643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/comments?post=22643"}],"version-history":[{"count":10,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/22643\/revisions"}],"predecessor-version":[{"id":45295,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/22643\/revisions\/45295"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/media?parent=22643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/categories?post=22643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/tags?post=22643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}