Skip to main content

Python library to work with ConceptNet offline

Project description

ConceptNet Rocks!

Work is in progress.

The library comes with Apache License 2.0, and is separate from ConceptNet itself, yet it uses some parts of its code. The ConceptNet is available under CC-BY-SA-4.0 license. See here for the list of conditions for using ConceptNet data.

This is the official citation for ConceptNet if you use it in research:

Robyn Speer, Joshua Chin, and Catherine Havasi. 2017. "ConceptNet 5.5: An Open Multilingual Graph of General Knowledge." In proceedings of AAAI 31.

Installation

pip install conceptnet-rocks

Usage

Install ArangoDB

ConceptNet Rocks uses ArangoDB as a storage. If you do not have it installed, simply execute the following command:

graph-garden arangodb install

This command will download the latest version of ArangoDB from official website and install it to ~/.arangodb folder. For more options execute:

graph-garden arangodb install --help

Load CSV dump into database

Then you need to load CSV dump into database. The dump can be downloaded from: https://github.com/commonsense/conceptnet5/wiki/Downloads

Let's assume you've downloaded the dump to ~/conceptnet-data/assertions.csv.

To load the dump, execute:

conceptnet-rocks-load ~/conceptnet-data/assertions.csv

This command will create database in ~/.arangodb/data. For more options execute:

conceptnet-rocks-load --help

Run queries

Now you can query ConceptNet. ConceptNet Rocks uses the same simple API as ConceptNet5 for querying:

from conceptnet_rocks import AssertionFinder

af = AssertionFinder()
print(af.lookup("/c/en/test"))
print(af.lookup("/r/Antonym"))
print(af.lookup("/s/process/wikiparsec/2"))
print(af.lookup("/d/wiktionary/en"))
print(af.lookup("/a/[/r/Antonym/,/c/ang/gecyndelic/a/,/c/ang/ungecynde/]"))

FAQ

Why did you create yet another library if original ConceptNet5 exists?

  1. Original ConceptNet5 library requires PostgreSQL. In general, this requires either root permissions to install it using package manager or compilation step. Not anyone have root permissions on their machine or have the compiler installed. ConceptNet Rocks library uses ArangoDB, which can be installed without root permissions using simple command.
  2. PostgreSQL does not support the graph databases as a primary model, while ArangoDB is a multi-model database for graph.
  3. Performance. Our benchmark (https://github.com/ldtoolkit/conceptnet-benchmark) has shown that ConceptNet Rocks is almost 5 times faster than ConceptNet5 for querying assertions by concepts.

Why is the library called ConceptNet Rocks?

  1. Under the hood ArangoDB uses key-value storage called RocksDB.
  2. In my opinion ConceptNet knowledge base really rocks!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conceptnet-rocks-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conceptnet_rocks-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file conceptnet-rocks-0.1.0.tar.gz.

File metadata

  • Download URL: conceptnet-rocks-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.9 Linux/5.8.7-1-default

File hashes

Hashes for conceptnet-rocks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 814db26266ad2ce3688e2e90e305c5724e6e4b4f5f5d9b1790c7cecea12d004b
MD5 00c057b59e49a9ae88f5a93e16c6816f
BLAKE2b-256 0f04f45bec217e03a45d8d449f6744c17396409ded57fc28498873dce07d325c

See more details on using hashes here.

File details

Details for the file conceptnet_rocks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: conceptnet_rocks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.9 Linux/5.8.7-1-default

File hashes

Hashes for conceptnet_rocks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f181f4db1f107deca8ef024badae0a96e556d1b00fe84757d4cdb501f125944c
MD5 a55a7b9bfac278db937d19a1d626bcaa
BLAKE2b-256 0c971c64b5bd4dfa0aec5d9fb7ea109aeceeaacb84bb351321ea752937c5936e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page