In [1]:
from watsongraph.conceptmodel import ConceptModel
import requests
import random
import time

Lets Concept all the things!!!

First we need to import the goodies. Then we will start with Python...


In [3]:
py = ConceptModel(['Python'])
py.concepts()


Out[3]:
['Python']

Now I am going to explode the and see what it does...


In [4]:
py.explode()
len(py.concepts())


Out[4]:
47

The next operation explores the edges of the concept


In [5]:
py.edges()


Out[5]:
[(0.9556251, 'Python (programming language)', 'Python'),
 (0.9391324, 'Perl', 'Python'),
 (0.9330337, 'Python', 'JavaScript'),
 (0.9329771, 'Ruby (programming language)', 'Python'),
 (0.9067886, 'Python', 'Cloud computing'),
 (0.88428956, 'Python', 'Graphical user interface'),
 (0.8606632, 'Python', 'Programming language'),
 (0.8562953, 'Python', 'GNU General Public License'),
 (0.854442, 'MySQL', 'Python'),
 (0.8541811, 'Python', 'Cross-platform'),
 (0.85204375, 'Python', 'GNU Lesser General Public License'),
 (0.848168, 'BSD licenses', 'Python'),
 (0.84645426, 'Software as a service', 'Python'),
 (0.8431103, 'Python', 'PHP'),
 (0.8181401, 'Python', 'Free software'),
 (0.81798714, 'Proprietary software', 'Python'),
 (0.8179362, 'Library (computing)', 'Python'),
 (0.8062557, 'Python', 'X Window System'),
 (0.79860413, 'Python', 'C Sharp (programming language)'),
 (0.77977175, 'Python', 'Unix-like'),
 (0.7726012, 'Amusement Today', 'Python'),
 (0.77066416, 'Python', 'C (programming language)'),
 (0.7663254, 'Python', 'C++'),
 (0.75602627, 'Solaris (operating system)', 'Python'),
 (0.74828255, 'Open source', 'Python'),
 (0.7479636, 'Python', 'Roller coaster'),
 (0.73240155, 'Python', 'Berkeley Software Distribution'),
 (0.7214403, 'Python', 'Java (programming language)'),
 (0.7199419, 'Python', 'Fortran'),
 (0.71639407, 'Python', 'FreeBSD'),
 (0.7152612, 'Python', '.NET Framework'),
 (0.714948, 'Python', 'Hypertext Transfer Protocol'),
 (0.6817643, 'Python', 'Object-oriented programming'),
 (0.6729798, 'Python', 'Compiler'),
 (0.6659008, 'Python', 'Unix'),
 (0.6571405, 'Python', 'Linux'),
 (0.63819724, 'Python', 'SQL'),
 (0.6358173, 'Python', 'Open-source software'),
 (0.6077114, 'Application programming interface', 'Python'),
 (0.59399706, 'Python', 'HTML'),
 (0.5875468, 'Python', 'Firefox'),
 (0.5859711, 'Source code', 'Python'),
 (0.52720386, 'Python', 'Server (computing)'),
 (0.519661, 'Python', 'Thrace'),
 (0.5131645, 'Python', 'Web browser'),
 (0.5038173, 'Python', 'XML')]

Expansion

The Concept Insights API returns its results in order of their relevance to the one at hand, but between the size of Wikipedia and the depth IBM Watson's own cognitive understanding this can result in unmanagably thousands of articles. To keep the information firehose at a managable level the Concept Insights service two parameters which are passed through by watsongraph graph-expansion methods: limit: The maximum number of concepts to be returned. Can be any int. Throttled to 50 by default. level: The popularity threshold of the articles that will be returned, on a 0 (highest) to 5 (lowest) scale. Throttled to 0 by default. The basic explode() command is a level-0 query. What happens when we play with the levels a bit?


In [7]:
database = ConceptModel(['Database'])
database.explode(limit=2000, level=1)
len(database.concepts())


Out[7]:
497

In [8]:
database.edges()[:20]


Out[8]:
[(0.9970014, 'Serializability', 'Database'),
 (0.9864219, 'Database', 'Relational model'),
 (0.9763615, 'Database', 'Relational database management system'),
 (0.97531044,
  'Comparison of relational database management systems',
  'Database'),
 (0.97359145, 'Database', 'Database management system'),
 (0.971852, 'Database', 'SQL'),
 (0.9713523, 'Entity–relationship model', 'Database'),
 (0.9710196, 'Relational database', 'Database'),
 (0.9700896, 'Database', 'Data warehouse'),
 (0.96675915, 'Database', 'NoSQL'),
 (0.9659734, 'ODBC', 'Database'),
 (0.9617862, 'Database', 'Data model'),
 (0.95844775, 'Database', 'IBM DB2'),
 (0.9569199, 'Database', 'Comparison of database tools'),
 (0.9565391, 'Oracle Database', 'Database'),
 (0.95113266, 'Database', 'Microsoft SQL Server'),
 (0.9459676, 'Sybase', 'Database'),
 (0.94461894, 'Microsoft Access', 'Database'),
 (0.93600625, 'SQLite', 'Database'),
 (0.9335352, 'MySQL', 'Database')]

In [11]:
py.edges()[:20]


Out[11]:
[(0.99995846, 'Open source', 'Source model'),
 (0.9999577, 'Proprietary license', 'Proprietary software'),
 (0.9999575, '.pyc', 'Python (programming language)'),
 (0.9999556, 'Application programming interface', 'Plugpoint'),
 (0.999954, 'Solaris Multiplexed I/O', 'Solaris (operating system)'),
 (0.99995375, 'Ruby programming', 'Ruby (programming language)'),
 (0.9999536, 'MySQL', 'Port 3306'),
 (0.9999532, 'BSD licenses', 'Prior BSD License'),
 (0.9999531, 'Library (computing)', 'Shared library form'),
 (0.9999473, 'Hybrid SaaS', 'Software as a service'),
 (0.99994236, 'Amusement Today', 'Millennium Flyer trains'),
 (0.9999188, 'PONIE', 'Perl'),
 (0.999917, 'Open-sourcing', 'Open source'),
 (0.99991506, 'Python implementations', 'Python (programming language)'),
 (0.9999125, 'Source code', 'Kelp annotation framework'),
 (0.9999111, 'Development API', 'Application programming interface'),
 (0.9999108, 'MySQL', 'IonPanel'),
 (0.99990964, 'Stmsboot', 'Solaris (operating system)'),
 (0.99990755, '.rb', 'Ruby (programming language)'),
 (0.9999065, 'BSD licenses', 'FreeBSD license')]

In [12]:
py.augment('Standard Library')
len(py.concepts())


Out[12]:
20373

In [13]:
py.neighborhood('Standard Library')


Out[13]:
[(1, 'Standard Library'),
 (0.9753888, '.NET Framework'),
 (0.97365093, 'Ruby (programming language)'),
 (0.96429616, 'Library (computing)'),
 (0.9560636, 'C++'),
 (0.9508998, 'C Sharp (programming language)'),
 (0.9282653, 'Object-oriented programming'),
 (0.92435837, 'Python (programming language)'),
 (0.92278373, 'C (programming language)'),
 (0.9141853, 'Programming language'),
 (0.91079116, 'Java (programming language)'),
 (0.9071287, 'Compiler'),
 (0.89290786, 'Perl'),
 (0.86092633, 'JavaScript'),
 (0.85140085, 'Fortran'),
 (0.8436945, 'GNU Lesser General Public License'),
 (0.8432706, 'PHP'),
 (0.8283033, 'BSD licenses'),
 (0.80861783, 'Cross-platform'),
 (0.793306, 'Source code'),
 (0.79315317, 'SQL'),
 (0.7924912, 'XML'),
 (0.7727616, 'Application programming interface'),
 (0.7336921, 'GNU General Public License'),
 (0.7312769, 'Computer program'),
 (0.72772276, 'Computer programming'),
 (0.712122, 'Unix-like'),
 (0.7105586, 'Unix'),
 (0.7099576, 'MySQL'),
 (0.69865865, 'Berkeley Software Distribution'),
 (0.6966567, 'Free software'),
 (0.69368196, 'Solaris (operating system)'),
 (0.677952, 'FreeBSD'),
 (0.6667156, 'X86'),
 (0.66451955, 'Graphical user interface'),
 (0.6568792, 'Open source'),
 (0.6512401, 'Sun Microsystems'),
 (0.64114267, 'Hypertext Transfer Protocol'),
 (0.6361026, 'X Window System'),
 (0.63265824, 'HTML'),
 (0.62076664, 'X86-64'),
 (0.6156682, 'Open-source software'),
 (0.61412317, 'Operating system'),
 (0.6116037, 'Linux'),
 (0.58794594, 'Firefox'),
 (0.5686235, 'Internet Explorer'),
 (0.5573005, 'Proprietary software'),
 (0.5542006, 'ARM architecture'),
 (0.54244435, 'Algorithm'),
 (0.534691, 'Oracle Corporation'),
 (0.5261502, 'Computing')]

Lets Start over with Python shall we? Yes we shall...


In [14]:
py.abridge('Standard Library')
len(py.concepts())


Out[14]:
20322

In [15]:
py.abridge('Python')
len(py.concepts())


Out[15]:
20314

In [16]:
py.abridge('Database')
len(py.concepts())


Out[16]:
20309

In [ ]:
py.remove()