IBM / build-knowledge-base-with-domain-specific-documents

Create a knowledge base using domain specific documents and the mammoth python library
https://developer.ibm.com/patterns/build-a-domain-specific-knowledge-graph-from-given-set-of-documents/
Apache License 2.0
132 stars 43 forks source link

Build a knowledge base with domain specific documents

In any business, word documents are a common occurence. They contain information in the form of raw text, tables and images. All of them contain important facts. The data used in this code pattern comes from two Wikipedia articles. The first is taken from the Wikipedia page of oncologist Suresh H. Advani the second is from the Wikipedia page about Oncology. These files are zipped up as archive.zip.

In the figure below, there is a textual information about an oncologist Suresh H. Advani present in a word document. The table consists of the awards that he has been awarded by various organisations.

output

In this Code pattern, we address the problem of extracting knowledge out of text and tables in word documents. A knowledge graph is built from the knowledge extracted making the knowledge queryable.

Some of the challenges in extracting knowledge from word documents are:

  1. The Natural Language Processing (NLP) tools cannot access the text inside word documents. The word documents need to be converted to plain text files.
  2. There are business and domain experts who understand the keywords and entities that are present in the documents. But training the NLP tool to extract domain specific keywords and entities is a big effort. Also, it is impractical in many scenarios to find sufficient number of documents to train the NLP tool to process the text.

This pattern uses the below methodology to overcome the challenges:

The best of both worlds - training and rules based approach is used to extract knowledge out of documents.

In this Pattern we will demonstrate:

What makes this Code Pattern valuable:

This Code Pattern is intended to help Developers, Data Scientists to give structure to the unstructured data. This can be used to shape their analysis significantly and use the data for further processing to get better Insights.

Flow

architecture

  1. The unstructured text data from the docx files (html tables and free floating text) that need to be analyzed and correlated is extracted from the documents using python code.
  2. Use Extend Watson text Classification text is classified using Watson NLU and also tagged using the code pattern - Extend Watson text classification
  3. The text is correlated with other text using the code pattern - Correlate documents
  4. The results are filtered using python code.
  5. The knowledge graph is constructed.

Video

video

Included components

Steps

Follow these steps to setup and run this code pattern. The steps are described in detail below.

  1. Create IBM Cloud services
  2. Run using a Jupyter notebook in the IBM Watson Studio
  3. Analyze the results

1. Create IBM Cloud services

Create the following IBM Cloud service and name it wdc-NLU-service:

2. Run using a Jupyter notebook in the IBM Watson Studio

  1. Create a new Watson Studio project
  2. Create the notebook
  3. Run the notebook
  4. Upload data
  5. Save and Share

2.1 Create a new Watson Studio project

2.2 Create the notebook

2.3 Run the notebook

2.4 Upload data

Upload the data and configuration to the notebook

NOTE: It is possible to use your own data and configuration files. If you use a configuration file from your computer, make sure to conform to the JSON structure given in data/config_classification.txt.

3. Analyze the results

As we step through the notebook we first the following:

graph

Learn more

Troubleshooting

See DEBUGGING.md.

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ