Click here to Skip to main content
Click here to Skip to main content

cnapinet - ConceptNet4 API Library

, 10 Aug 2010 GPL3
Rate this:
Please Sign up or sign in to vote.
Connect to ConceptNet's REST API

(Note: cnapinet.dll has Newtonsoft.Json.dll dependency for json handling.)

cnapinet_scrn.jpg cnapinet_scrn2.jpg cnapinet_obj.jpg

Introduction

ConceptNet¹ is a commonsense knowledgebase, composed mainly from the Open Mind Project, written and maintained by Massachusetts Institute of Technology (MIT).  ConceptNet 4 (current version at the time of this composition) is natively written in PythonConceptNet, for example, could be useful in an application to link certain ideas together for organizational purposes.  My selfish reason for developing this library is because I can quickly throw my coding ideas in C# and I didn't see anyone develop a .NET library for ConceptNet API yet.  Also, I haven't really used ConceptNet since version 2.1 so I decided to spend some time and hammer something out.

The .NET C# ConceptNet API Class Library (cnapinet)

cnapinet can provide an interface to ConceptNet REST API.  It is based on the Python client API rest_client.py. Use the API to receive back Lists and objects of a ConceptNet concept.

cnapinet Namespace

cnapinet_ns.jpg cnapinet_classes.jpg

The Demo

The demo app has two sections: Relationship/Text and the Output box. To make it easy, I listed all of the possible Relational Ontologies in the dropdown box [IsA, HasA, HasSubevent, etc.].  I also kept the domain grouping found in the previous version of  ConceptNet. Next to the dropdown box, there is a textbox to place a word or phrase. Lastly, clicking the 'lookup' button will run through the several API calls and display the objects returned.

cnapinet Implementation

  1. Add cnapinet.dll to your project 'References' via Solution Explorer. (For cnapinet.dll v1.3.x.x, make sure that Newtonsoft.Json.dll resides in the same folder as cnapinet.dll) .
  2. Add 'using cnapinet;', etc. to your source code to use the namespace.
  3. Create the main API engine with 'ConceptNetAPI CNClient = new ConceptNetAPI();', etc.
  4. Below are the methods in ConceptNetAPI:

ConceptNetAPIMembers.jpg

Conclusion

I didn't see any .NET libraries for the ConceptNet REST API so I decided to create one based on the Python client API rest_client.py. I plan to use it with some applications I have in mind to help group information together in a meaningful way instead of alphabetical or chronological.  Some of my previous articles with older versions were more embedded with Python and IronPython; with ConceptNet still being in active development (soon version 5 will be released), it is becoming easier to access its data.

References

  • The ConceptNet Web API, Massachusetts Institute of Technology [^]
  • Newtonsoft.Json.dll, Json.NET Copyright (c) 2007 James Newton-King [^]
  • Open Mind Common Sense Project [^]

Updates

  • 8/10/10
    • Uploaded CNAPINetDemo v1.3.0.0 Microsoft Visual C# Express 2010 project files
    • Uploaded cnapinet.dll v1.3.0.0 and necessary files

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

JoeSox
Network Administrator
United States United States
Born in Pennsylvania (USA), just north of Philadelphia. Joe has been programming since he was ten[now much older]. He is entirely self-taught programmer, and he is currently working as a Network Administrator (and a bunch of other crap) in Seattle WA. He was previously U.S. Navy Active Reservist for (SPAWAR)
In '98 was honorably discharged from the USN. He served onboard the USS Carl Vinson (94-98) He was lucky enough to drink President Clinton's leftover wine, promoted by his Captain, and flew in a plane off the flightdeck but not all at the same time. His interests, when time allows, are developing
misc apps and Artificial Intelligence proof-of-concept demos that specifically exhibits human behavior. He is a true sports-a-holic, needs plenty of caffeine, and a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, and new alternative music fan.
 
Joe is an INTP[^] personality type. Joe "sees everything in terms of how it could be improved, or what it could be turned into. INTP's live primarily inside their own minds." INTPs also can have the "greatest precision in thought and language. Can readily discern contradictions and inconsistencies. The world exists primarily to be understood. 1% of the total population" [
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
QuestionConceptNet5 API Library here... PinmemberJoeSox17-Dec-11 13:52 
cn5apinet - ConceptNet5 API Library[^]

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 10 Aug 2010
Article Copyright 2010 by JoeSox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid