{"id":1244,"date":"2018-05-09T12:53:13","date_gmt":"2018-05-09T17:53:13","guid":{"rendered":"http:\/\/haleyai.com\/wordpress\/?p=1244"},"modified":"2018-07-13T18:27:28","modified_gmt":"2018-07-13T23:27:28","slug":"importing-documents-into-a-knowledge-base","status":"publish","type":"post","link":"http:\/\/haleyai.com\/wordpress\/2018\/05\/09\/importing-documents-into-a-knowledge-base\/","title":{"rendered":"Importing documents into a knowledge base"},"content":{"rendered":"<p>Many users land up wanting to import sentences in the Linguist rather than type or paste them in one at a time.\u00a0 One way to do this is to right click on a group within the Linguist and  import a file of sentences, one per line, into that group.\u00a0 But if you want to import a large document and retain its outline structure, some application-specific use of the Linguist APIs may be the way to go.<\/p>\n<div>We&#8217;ve written up <a href=\"https:\/\/linguist.haleyai.com\/ImportingCaliforniaSalesAndUseTax.html\">how to import<\/a> a whole web site\u00a0 on <a href=\"http:\/\/www.boe.ca.gov\/lawguides\/business\/current\/btlg\/vol1\/sutl\/sales-and-use-tax-law-chapters.html\">California Sales &amp; Use Tax<\/a>:<\/div>\n<div><a href=\"http:\/\/www.boe.ca.gov\/lawguides\/business\/current\/btlg\/vol1\/sutl\/sales-and-use-tax-law-chapters.html\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1245\" title=\"image001\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image0011.jpg\" alt=\"\" width=\"624\" height=\"480\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image0011.jpg 624w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image0011-300x230.jpg 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/a><\/div>\n<div><!--more-->There are quite a few ways to do this, but we took the step by step approach of:<\/div>\n<div>\n<ol>\n<li>walk the web site and extract the content of the law into a number of files<\/li>\n<li>process the files into a the content of individual sections within an outline structure<\/li>\n<li>break the content down into individual sentences<\/li>\n<li>create the outline structure and populate it with the sentences<\/li>\n<\/ol>\n<div>The resulting knowledge base is ready for text analysis, automated parsing, and disambiguation, as shown here:<\/div>\n<div><a href=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image032.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1246\" title=\"outliine of sales &amp; use tax law knowledge base\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image032.jpg\" alt=\"\" width=\"1361\" height=\"705\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image032.jpg 1361w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image032-300x155.jpg 300w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/image032-1023x530.jpg 1023w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/div>\n<div>\n<p>Our favorite case is importing pages from web sites, such as  Wikipedia or regulatory text that appears on-line.\u00a0 For the most part,  the text is available as HTML.\u00a0 In some cases, it&#8217;s available as Word  documents.\u00a0 And sometimes it&#8217;s only available as PDF.<\/p>\n<ul>\n<li> PDF documents can be saved as text, imported into Word, or read programmatically<\/li>\n<li>Microsoft Word is no problem since it can be saved as HTML<\/li>\n<li>The Linguist has utilities that extract the HTML from ePub textbooks<\/li>\n<li>The Linguist also has utilities that extract text from PDFs, but PDFs typically require more work\n<ul>\n<li>PDF can be saved to text (possibly with in-line headers &amp; footers)<\/li>\n<li>PDF can be imported by Word (sometimes losing headers &amp; flow)<\/li>\n<li>Mutli-column PDF can be difficult if the flow of the document is not clear<\/li>\n<li>PDF can be difficult if there is excess hyphenation due to even justification<\/li>\n<\/ul>\n<\/li>\n<li>HTML can be transformed into XML which is easy to process in various languages (e.g., Java).<\/li>\n<\/ul>\n<div>In the article we discuss a number of finer points, especially with regard to tokenization and sentence splitting.<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Many users land up wanting to import sentences in the Linguist rather than type or paste them in one at a time.\u00a0 One way to do this is to right click on a group within the Linguist and import a file of sentences, one per line, into that group.\u00a0 But if you want to import &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/haleyai.com\/wordpress\/2018\/05\/09\/importing-documents-into-a-knowledge-base\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Importing documents into a knowledge base&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[596,877,532,527,595,785,873,874,872,875,312,876],"class_list":["post-1244","post","type-post","status-publish","format-standard","hentry","category-knowledge-management","tag-html","tag-importing","tag-knowledge-base","tag-linguist","tag-pdf","tag-sales-tax","tag-sentence-splitting","tag-tokenization","tag-use-tax","tag-web-crawling","tag-word","tag-xml"],"_links":{"self":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/1244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1244"}],"version-history":[{"count":6,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/1244\/revisions"}],"predecessor-version":[{"id":1502,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/1244\/revisions\/1502"}],"wp:attachment":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}