Git Product home page Git Product logo

knowledge_graph_with_neo4j's Introduction

Create a Knowledge Graph using Corpus from Wikipedia

To setup the database Neo4j type the command

docker-compose up

This will start pull the docker image from docker hub and start the database at port 7474. So the database URL is: http://localhost:7474. Credentials for the database.

username: neo4j
password: kgDemo

Save these credentials in a .py file and name that file config.py. These credentials can be changed from the docker-compose.yml file. The config.py file should look like this:

neo4j_url = "bolt://localhost:7687"
neo4j_username = "neo4j"
neo4j_password = "kgDemo"

Now to install the necessary packages run the command: pip install -r requirements.txt. It's better to use virtual environment to install the packages.

Spacy model is needed to tokenize texts. To download the model, run the command:

python3 -m spacy download en_core_web_md

To get an initial corpus of wikipedia run the script build_corpus.py. This will download the corpus from wikipedia and save it in a corpus.txt file. The corpus topics can be changed in the file build_corpus.py to get wikipedia summary for preferred pages.

To use the Google Knowledge Graph API we will need to create a project in Google Cloud Platform and get an API. The API is free and can be used for a limited number of requests (100,000 Per day). The instructions can be found here.

Paste the API key in a file and name it api_key and put it in the parent directory.

Now to start processing the corpus and build the knowledge graph run the file main.py.

This will take quite some time as this file cleans the text, tokenizes them, removes stop words, stems them and creates the nodes and edges in the database. After the file run is complete we can visualize the graph in Neo4j.

To watch all the nodes with all the connections run the command:

MATCH (n) RETURN n

To watch all the nodes connected to a node run the command:

MATCH (n:Node {name: "<a node name>"}) -- (m:Node) return m.name

knowledge_graph_with_neo4j's People

Contributors

sifatnabil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.