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

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

Introduction

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.CNDB ConceptNetDB.py
ConceptNetUtils.CNTools ConceptNetNLTools.py
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 the latest release IronPython (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 CNUDB.py (Line 10) and CNUMontylingua.py (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.)

Conclusion

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.

References

  • ¹ 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 [^]

Updates

  • 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 array.py 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

License

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

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

 
QuestionNN , NX ,PRP ,VX , DT, JJ Meaning Pinmemberahmdmahmoud27-Jun-12 2:56 
AnswerRe: NN , NX ,PRP ,VX , DT, JJ Meaning PinmemberJoeSox27-Jun-12 4:41 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pinmemberahmdmahmoud27-Jun-12 4:45 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning Pinmemberahmdmahmoud28-Jun-12 23:45 
GeneralRe: NN , NX ,PRP ,VX , DT, JJ Meaning PinmemberJoeSox29-Jun-12 12:23 
QuestionConceptNet 5 Pinmemberahmdmahmoud19-Jun-12 23:15 
AnswerRe: ConceptNet 5 PinmemberJoeSox20-Jun-12 2:23 
GeneralRe: ConceptNet 5 Pinmemberahmdmahmoud20-Jun-12 2:34 
GeneralRe: ConceptNet 5 PinmemberJoeSox20-Jun-12 8:28 
QuestionRuntime error Pinmemberahmdmahmoud18-Jun-12 4:53 
AnswerRe: Runtime error PinmemberJoeSox18-Jun-12 14:02 
GeneralRe: Runtime error Pinmemberahmdmahmoud18-Jun-12 21:51 
GeneralRe: Runtime error Pinmemberahmdmahmoud18-Jun-12 23:31 
QuestionCalls in IronPython.Runtime.Calls are not found Pinmembersabry.rizk24-Dec-11 8:38 
AnswerRe: Calls in IronPython.Runtime.Calls are not found PinmemberJoeSox24-Dec-11 9:40 
GeneralRe: Calls in IronPython.Runtime.Calls are not found Pinmembersabry.rizk24-Dec-11 21:48 
GeneralRe: Calls in IronPython.Runtime.Calls are not found Pinmembersabry.rizk24-Dec-11 23:05 
GeneralRe: Calls in IronPython.Runtime.Calls are not found PinmemberJoeSox25-Dec-11 4:14 
Generalcan't get demo to work :( :( :( Pinmemberjayachanakya26-May-11 20:43 
GeneralRe: can't get demo to work :( :( :( PinmemberJoeSox27-May-11 3:39 
Generalproblem! please help :( Pinmemberdorielle10-May-10 23:59 
GeneralRe: problem! please help :( PinmemberJoeSox11-May-10 3:39 
GeneralRe: problem! please help :( Pinmemberdorielle11-May-10 22:37 
GeneralRe: problem! please help :( PinmemberJoeSox12-May-10 6:47 
GeneralRe: problem! please help :( Pinmemberdorielle12-May-10 12:24 

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
Web01 | 2.8.140827.1 | Last Updated 24 Mar 2007
Article Copyright 2006 by JoeSox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid