Click here to Skip to main content
13,349,997 members (48,882 online)
Click here to Skip to main content
Add your own
alternative version


32 bookmarked
Posted 17 Jul 2006

C# ConceptNetUtils (CNU) Version 2

, 24 Mar 2007
Rate this:
Please Sign up or sign in to vote.
A C# dynamic link library that runs ConceptNet: A Semantic Network of Common Sense

Sample Image - cnu2.jpg


ConceptNet¹ is a commonsense knowledgebase, composed mainly from the Open Mind Project, written and put together by Hugo Liu and Push Singh (Media Laboratory Massachusetts Institute of Technology). ConceptNet 2.1 (current version at the time of this composition) also includes MontyLingua, a natural-language-processing package. ConceptNet is written in Python but it's commonsense knowledgebase is stored in text files. To read more specific details about the complete overview of ConceptNet, read Liu and Singh's outstanding paper (pdf). Most of the projects available from MIT are not written in Microsoft Visual Studio .NET and I am attempting to make use of ConceptNet for educational, research purposes, and just to have fun with the technology involved. This version is 2.x. It is closely integrated with Microsoft's IronPython.

The Visual Studio .NET C# ConceptNetUtils (CNU) Version 2.x Class Library

ConceptNetUtils (CNU) version 2 uses IronPython and edited ConceptNet script files to achieve the same results as the Python version of ConceptNet. The only con is that there is some speed lost when loading and creating the semantic network using ConceptNetUtils. This loss is not much and probably worth the price considering the positives of having a .NET compatible ConceptNet. Below is a summary of CNU's methods and namespaces. Most of the detailed documentation and explanations are found within the code itself, as well as ConceptNet's documentation. You may also read my first article Having fun with MIT's ConceptNet 2.1 in C#.

CNU's Namespaces

CNU ConceptNet
ConceptNetUtils.Monty Misc MontyLingua module support



CNU What It Does
ConceptNetUtils.Converts Misc. conversion helper methods that are not ConceptNet related.
ConceptNetUtils.Misc A mixture of ConceptNet and non-ConceptNet related helper methods. (As of CNU v2.7.9.0b, this namespace is still being constructed by all of MontyLingua is still accessible if you load the CNU *.py script files direction thru IronPython. These script files are embedded and also found in the "...\CNU\ConceptNetUtils2\ConceptNetUtils2" path of the CNU project.
[e.g. engine1.Execute("import CNUMontylingua")])
ConceptNetUtils.Forms As of CNU v2.7.9.0b, this namespace has two classes.
FileOptionsForm is a System.Windows.Forms.Form for setting the options for loading ConceptNet's predicate files or your own predicate files.
ProgressbarForm is a System.Windows.Forms.Form for displaying a progressbar when loading the predicate files.
ConceptNetUtils.IPEWrapper PythonEngine's output is in Stream so this class helps obtain that output.
ConceptNetUtils.Paths MiscDirs: Holds misc. directory paths (ConceptNet paths located here.)
Python24Dirs: Holds your common Python 2.4 paths
IronPythonDirs: Holds your common IronPython paths.



The Demo

ConceptNet 2.1 comes with its own Python demo named "ConceptNet Mini-Browser." It explores the ConceptNet API interactively. The ConceptNetUtils demo is a .NET version of that mini-browser. It first loads MontyLingua's Natural Language Processing methods and rules, then it loads ConceptNet's default predicate files. (It is recommended that you have a 2.0 GHZ processor or higher or you may have to wait five minutes for semantic network to be created). In the textbox, enter some input text (a word, word phrase, sentence, or sentences) then either click on the green buttons ("node-level" modes: handles words and word phrases) or the yellow buttons ("document-level" modes: handles sentences and paragraphs).

  • BROWSE: Displays matching predicate nodes from node-level text input. (ConceptNetUtils.CNDB.display_node(): Returns IronPython List of the matching predicate nodes from a node-level text)
  • CONTEXT: Displays matching related topics. Returns IronPython List of related topics from node-level text input. (ConceptNetUtils.CNDB.get_context(): Returns IronPython List of related topics.)
  • PROJECTION: Computes all available contextual projections (Consequences, Details, Spatial, and Affective) from node-level text input. (ConceptNetUtils.CNDB.get_all_projections(): Returns an IronPython List of pairs.)
  • ANALOGY: Displays a list of rank-ordered concepts from node-level text input. (ConceptNetUtils.CNDB.get_analogous_concepts(): Returns an IronPython List of rank-ordered concepts if simple_results_p = 1.)
  • GUESS CONTEXT: Displays list of most likely context from document-level text input.
  • GUESS TOPIC: Displays list of most likely related topics from document-level text input.
  • GUESS MOOD: Displays percentage of most likely emotions (happy, sad, angry, fearful, disgusted, surprised) from document-level text input.
  • SUMMARIZE: Displays an interpretation in sentence form from document-level text input.

How to Run the Demo

  1. Download ConceptNet 2.1 (recommended extraction to ...\My Documents\Python Projects\conceptnet2.1)
  2. Download Python 2.4 (recommended extraction to C:\Python24)
  3. Download (recommended extraction to ...\My Documents\Visual Studio 2005\Projects)
  4. Download and unzip this article's .NET Solution and project files. Open CNUtils2Demo.sln.
  5. Manually edit the local paths in (Line 10) and (Line 8) [files may be found in the Solution Explorer] to point to your conceptnet2.1 and conceptnet2.1\montylingua directories.
  6. From Microsoft VC# 2005 Solution Explorer, Add a Reference by browsing to IronPython.dll and IronMath.dll located where you extracted the IronPython download.
  7. ReBuild both projects in the solution. The demo should now be able to execute.

(Please Note: I recommend running this demo if you have a 2.0 GHZ processor or above, otherwise you may be waiting more than 5 minutes for the semantic network to be created.)


ConceptNet 2.1 can be a tool to create personalized commonsense knowledgebase networks. Included in the ConceptNet 2.1 download is MontyLingua. It is a quick and easy implementation for Natural Language Processing once when you learn how it operates. Hopefully, this Microsoft Visual Studio .NET Class Library project can be informational, useful, and fun.


  • ¹ Liu, H. & Singh, P. (2004) ConceptNet: A Practical Commonsense Reasoning Toolkit. BT Technology Journal, To Appear. Volume 22, forthcoming issue. Kluwer Academic Publishers. (any modifications to ConceptNet source code have been documented in the CNU*.py files as per ConceptNet's terms of use license.) [^]
  • ConceptNet: A Practical Commonsense Reasoning Toolkit, Hugo Liu and Push Singh Media Laboratory Massachusetts Institute of Technology [^]
  • Investigating ConceptNet, Dustin Smith; Advisor: Stan Thomas, Ph.D. December 2004 [^]
  • Open Mind Common Sense Project [^]
  • IronPython: Workspace Home [^]
  • The Official Python Language Website [^]


  • 7/17/06
    • Uploaded CNUtils2Demo v1.0.0.0rc project files
    • Uploaded ConceptNetUtils2.dll v2.7.9.1b including CNU*.py scripts (Note: ConceptNetUtils2.dll has IronPython.dll and CNU*.py script dependency)
  • 7/25/06
    • Uploaded CNUtils2Demo with updated ConceptNetUtils2 project files
    • Uploaded ConceptNetUtils2.dll v2.7.9.3b
    • Changed class ConceptNetUtils.Monty.Monty to ConceptNetUtils.Monty.MontyLingua
    • Updated ConceptNetUtils.Monty.MontyLingua using dir(c.nltools.m) for fastest performance
    • Added: {jist_predicates(), jist(), split_paragraphs(), split_sentences()} methods to ConceptNetUtils.Monty.MontyLingua
  • 7/26/06
    • Updated need to support IronPython-1.0-RC1
    • Uploaded CNUtils2Demo with updated ConceptNetUtils2 project files
    • Uploaded ConceptNetUtils2.dll v2.8.0.0rc
  • 2/27/07
    • Please NOTE: IronPython 1.1 Beta 1 will not work with CNU due to the new built in array module. The IronPython Dev Team will fix this for the next release
    • Started development for a CNU XML-RPC Class that works directly with ConceptNetXMLRPCServer
  • 3/24/07
    • Uploaded ConceptNetUtils2.dll v2.8.2.0rc. Removed since built-in array has been since modified to resemble CPython, so no problems now. IronPython-1.1RC1 is currently the only version of IronPython that will work with ConceptNetUtils2.dll v2.8.2.0rc
    • Successfully tested with IronPython-1.1RC1


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

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 an IT Manager 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, new alternative music fan, and the Chainsmokers.

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" [

You may also be interested in...

Comments and Discussions

QuestionIs this still working !!! Pin
Member 1024814525-Nov-15 23:57
memberMember 1024814525-Nov-15 23:57 
AnswerRe: Is this still working !!! Pin
JoeSox26-Nov-15 4:08
professionalJoeSox26-Nov-15 4:08 
GeneralRe: Is this still working !!! Pin
Member 1024814526-Nov-15 5:05
memberMember 1024814526-Nov-15 5:05 
GeneralRe: Is this still working !!! Pin
JoeSox26-Nov-15 9:52
professionalJoeSox26-Nov-15 9:52 
GeneralRe: Is this still working !!! Pin
Member 1024814527-Nov-15 10:03
memberMember 1024814527-Nov-15 10:03 
GeneralRe: Is this still working !!! Pin
JoeSox27-Nov-15 18:47
professionalJoeSox27-Nov-15 18:47 
QuestionNN , NX ,PRP ,VX , DT, JJ Meaning Pin
ahmdmahmoud27-Jun-12 3:56
memberahmdmahmoud27-Jun-12 3:56 
AnswerRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pin
JoeSox27-Jun-12 5:41
memberJoeSox27-Jun-12 5:41 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pin
ahmdmahmoud27-Jun-12 5:45
memberahmdmahmoud27-Jun-12 5:45 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pin
ahmdmahmoud29-Jun-12 0:45
memberahmdmahmoud29-Jun-12 0:45 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pin
JoeSox29-Jun-12 13:23
memberJoeSox29-Jun-12 13:23 
QuestionConceptNet 5 Pin
ahmdmahmoud20-Jun-12 0:15
memberahmdmahmoud20-Jun-12 0:15 
AnswerRe: ConceptNet 5 Pin
JoeSox20-Jun-12 3:23
memberJoeSox20-Jun-12 3:23 
GeneralRe: ConceptNet 5 Pin
ahmdmahmoud20-Jun-12 3:34
memberahmdmahmoud20-Jun-12 3:34 
GeneralRe: ConceptNet 5 Pin
JoeSox20-Jun-12 9:28
memberJoeSox20-Jun-12 9:28 
QuestionRuntime error Pin
ahmdmahmoud18-Jun-12 5:53
memberahmdmahmoud18-Jun-12 5:53 
AnswerRe: Runtime error Pin
JoeSox18-Jun-12 15:02
memberJoeSox18-Jun-12 15:02 
GeneralRe: Runtime error Pin
ahmdmahmoud18-Jun-12 22:51
memberahmdmahmoud18-Jun-12 22:51 
GeneralRe: Runtime error Pin
ahmdmahmoud19-Jun-12 0:31
memberahmdmahmoud19-Jun-12 0:31 
QuestionCalls in IronPython.Runtime.Calls are not found Pin
sabry.rizk24-Dec-11 9:38
membersabry.rizk24-Dec-11 9:38 
AnswerRe: Calls in IronPython.Runtime.Calls are not found Pin
JoeSox24-Dec-11 10:40
memberJoeSox24-Dec-11 10:40 
GeneralRe: Calls in IronPython.Runtime.Calls are not found Pin
sabry.rizk24-Dec-11 22:48
membersabry.rizk24-Dec-11 22:48 
GeneralRe: Calls in IronPython.Runtime.Calls are not found Pin
sabry.rizk25-Dec-11 0:05
membersabry.rizk25-Dec-11 0:05 
GeneralRe: Calls in IronPython.Runtime.Calls are not found Pin
JoeSox25-Dec-11 5:14
memberJoeSox25-Dec-11 5:14 
Generalcan't get demo to work :( :( :( Pin
jayachanakya26-May-11 21:43
memberjayachanakya26-May-11 21:43 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 24 Mar 2007
Article Copyright 2006 by JoeSox
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid