Skip to content

Instantly share code, notes, and snippets.

@tomoyanonymous
Created October 9, 2018 18:01
Show Gist options
  • Save tomoyanonymous/1112ab196b5a191b3298c7b02c2f9bfc to your computer and use it in GitHub Desktop.
Save tomoyanonymous/1112ab196b5a191b3298c7b02c2f9bfc to your computer and use it in GitHub Desktop.
Scrapism-week4
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction for [TextBlob](https://textblob.readthedocs.io/en/)\n",
"## split sentences and words"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from textblob import TextBlob"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"blob = TextBlob(\"TextBlob is a Python (2 and 3) library for processing textual data. It provides a consistent API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, and more. Blob-class is wrappers for various units of text, including the main TextBlob, Word, and WordList classes.\")"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Sentence(\"TextBlob is a Python (2 and 3) library for processing textual data.\"),\n",
" Sentence(\"It provides a consistent API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, and more.\"),\n",
" Sentence(\"Blob-class is wrappers for various units of text, including the main TextBlob, Word, and WordList classes.\")]"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"blob.sentences"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----\n",
"TextBlob\n",
"is\n",
"a\n",
"Python\n",
"2\n",
"and\n",
"3\n",
"library\n",
"for\n",
"processing\n",
"textual\n",
"data\n",
"----\n",
"It\n",
"provides\n",
"a\n",
"consistent\n",
"API\n",
"for\n",
"diving\n",
"into\n",
"common\n",
"natural\n",
"language\n",
"processing\n",
"NLP\n",
"tasks\n",
"such\n",
"as\n",
"part-of-speech\n",
"tagging\n",
"noun\n",
"phrase\n",
"extraction\n",
"sentiment\n",
"analysis\n",
"and\n",
"more\n",
"----\n",
"Blob-class\n",
"is\n",
"wrappers\n",
"for\n",
"various\n",
"units\n",
"of\n",
"text\n",
"including\n",
"the\n",
"main\n",
"TextBlob\n",
"Word\n",
"and\n",
"WordList\n",
"classes\n"
]
}
],
"source": [
"for sentence in blob.sentences:\n",
" print(\"----\")\n",
" for word in sentence.words:\n",
" print(word)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use a tags\n",
"**[Penn Treebank Part-of-Speech tags](https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html)** "
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('A', 'DT')\n",
"word is A . speech tag is DT\n",
"('specter', 'NN')\n",
"word is specter . speech tag is NN\n",
"('is', 'VBZ')\n",
"word is is . speech tag is VBZ\n",
"('haunting', 'VBG')\n",
"word is haunting . speech tag is VBG\n",
"('this', 'DT')\n",
"word is this . speech tag is DT\n",
"('small', 'JJ')\n",
"word is small . speech tag is JJ\n",
"('classroom', 'NN')\n",
"word is classroom . speech tag is NN\n",
"('The', 'DT')\n",
"word is The . speech tag is DT\n",
"('specter', 'NN')\n",
"word is specter . speech tag is NN\n",
"('of', 'IN')\n",
"word is of . speech tag is IN\n",
"('sleepiness', 'NN')\n",
"word is sleepiness . speech tag is NN\n"
]
}
],
"source": [
"for tag in blob.tags:\n",
" print(tag)#tuple!!!\n",
" print(\"word is \",tag[0],\". speech tag is \",tag[1])"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"library\n",
"language\n",
"processing\n",
"tagging\n",
"phrase\n",
"extraction\n",
"sentiment\n",
"analysis\n",
"text\n"
]
}
],
"source": [
"#filter \n",
"for tag in blob.tags:\n",
" if tag[1]==\"NN\":\n",
" print(tag[0])"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"is\n",
"processing\n",
"provides\n",
"diving\n",
"is\n",
"including\n"
]
}
],
"source": [
"#filter \n",
"for tag in blob.tags:\n",
" if \"VB\" in tag[1]: #bit tricky, but this filters VB,VBZ,VBP,,,,\n",
" print(tag[0])"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"textblob\n",
"python\n",
"processing textual data\n",
"api\n",
"common natural language processing\n",
"nlp\n",
"noun phrase extraction\n",
"sentiment analysis\n",
"blob-class\n",
"various units\n",
"textblob\n",
"wordlist\n"
]
}
],
"source": [
"for np in blob.noun_phrases: #print combined-noun\n",
" print(np)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TextBlob is a Python 2 and 3 libraries for processing textual data It provides a consistent API for diving into common natural languages processings NLP tasks such as part-of-speech taggings noun phrases extractions sentiments analyses and more Blob-class is wrappers for various units of texts including the main TextBlob Word and WordList classes\n"
]
}
],
"source": [
"word = []\n",
"for tag in blob.tags:\n",
" word.append(tag[0].pluralize()) if tag[1]==\"NN\" else word.append(tag[0])\n",
"print(\" \".join(word))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Classify texts\n",
"### training texts"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"from textblob.classifiers import NaiveBayesClassifier"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"train = [\n",
" (\"A spector is haunting europe\", \"communist\"),\n",
" (\"The specter of communism\",\"communist\"),\n",
" (\"Long live the proletariate\",\"communist\"),\n",
" (\"commodities are dumb\",\"communist\"),\n",
" \n",
" (\"Free markets are good\",\"capitalist\"),\n",
" (\"Buy low sell high\",\"capitalist\"),\n",
" (\"$$$$\",\"capitalist\"),\n",
" (\"Venture capitalism is great\",\"capitalist\")\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"cl = NaiveBayesClassifier(train)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"communist\n",
"capitalist\n"
]
}
],
"source": [
"print(cl.classify(\"A spector is haunting this classroom.\"))\n",
"print(cl.classify(\"Let's buy a sofa\"))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.15517241379310354\n"
]
}
],
"source": [
"pb= cl.prob_classify(\"A spector \")\n",
"print(pb.prob(\"capitalist\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# using Conceptnet\n",
"http://conceptnet.io/\n",
"\n",
"you can get synonyms, usage and so on,,, http://conceptnet.io/c/en/hello\n",
"\n",
"and also you can get same result as a api http://api.conceptnet.io/c/en/hello"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import time\n",
"from pprint import pprint"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"http://api.conceptnet.io/c/en/glass\n",
"{'@context': ['http://api.conceptnet.io/ld/conceptnet5.6/context.ld.json'],\n",
" '@id': '/c/en/glass',\n",
" 'edges': [{'@id': '/a/[/r/RelatedTo/,/c/en/window/,/c/en/glass/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/window',\n",
" '@type': 'Node',\n",
" 'label': 'window',\n",
" 'language': 'en',\n",
" 'term': '/c/en/window'},\n",
" 'surfaceText': '[[window]] is related to [[glass]]',\n",
" 'weight': 8.952764936040708},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/window/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/window',\n",
" '@type': 'Node',\n",
" 'label': 'window',\n",
" 'language': 'en',\n",
" 'term': '/c/en/window'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[window]]',\n",
" 'weight': 7.485185368446128},\n",
" {'@id': '/a/[/r/UsedFor/,/c/en/glass/,/c/en/drinking/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/drinking',\n",
" '@type': 'Node',\n",
" 'label': 'drinking',\n",
" 'language': 'en',\n",
" 'term': '/c/en/drinking'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/UsedFor',\n",
" '@type': 'Relation',\n",
" 'label': 'UsedFor'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/buzzy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/buzzy'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/discostu/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/discostu'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/browni/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/browni'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/buzzy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/buzzy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/cffrost/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/cffrost'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/cgr6513/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/cgr6513'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/dvyjones/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/dvyjones'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/justjim/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/justjim'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/rolius/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/rolius'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/sandos/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/sandos'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/slux/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/slux'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/spacecad/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/spacecad'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/supermidget/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/supermidget'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/tim/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/tim'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'a glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[a glass]] is used for [[drinking]]',\n",
" 'weight': 7.211102550927979},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/clear/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/clear',\n",
" '@type': 'Node',\n",
" 'label': 'clear',\n",
" 'language': 'en',\n",
" 'term': '/c/en/clear'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[clear]]',\n",
" 'weight': 6.563840339313565},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/material/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/material',\n",
" '@type': 'Node',\n",
" 'label': 'material',\n",
" 'language': 'en',\n",
" 'term': '/c/en/material'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[material]]',\n",
" 'weight': 6.041522986797286},\n",
" {'@id': '/a/[/r/ReceivesAction/,/c/en/glass/,/c/en/broken/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/broken',\n",
" '@type': 'Node',\n",
" 'label': 'broken',\n",
" 'language': 'en',\n",
" 'term': '/c/en/broken'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/ReceivesAction',\n",
" '@type': 'Relation',\n",
" 'label': 'ReceivesAction'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/otradovec/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/otradovec'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/phraughy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/phraughy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/burgun/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/burgun'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/lemony/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/lemony'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/otradovec/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/otradovec'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/phraughy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/phraughy'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'A glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[A glass]] can be [[broken]]',\n",
" 'weight': 5.291502622129181},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/drinking/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/drinking',\n",
" '@type': 'Node',\n",
" 'label': 'drinking',\n",
" 'language': 'en',\n",
" 'term': '/c/en/drinking'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[drinking]]',\n",
" 'weight': 5.047771785649585},\n",
" {'@id': '/a/[/r/CapableOf/,/c/en/glass/,/c/en/hold_liquid/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/hold_liquid',\n",
" '@type': 'Node',\n",
" 'label': 'hold liquid',\n",
" 'language': 'en',\n",
" 'term': '/c/en/hold_liquid'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/CapableOf',\n",
" '@type': 'Relation',\n",
" 'label': 'CapableOf'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/halelaniau/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/halelaniau'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/biomes/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/biomes'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/hyperham/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/hyperham'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/ibell/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/ibell'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/jasongross/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/jasongross'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/leiam/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/leiam'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/rspeer/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/rspeer'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'A glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[A glass]] can [[hold liquid]]',\n",
" 'weight': 4.898979485566356},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/transparent/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/transparent',\n",
" '@type': 'Node',\n",
" 'label': 'transparent',\n",
" 'language': 'en',\n",
" 'term': '/c/en/transparent'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[transparent]]',\n",
" 'weight': 4.846441993875507},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/windows/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/windows',\n",
" '@type': 'Node',\n",
" 'label': 'windows',\n",
" 'language': 'en',\n",
" 'term': '/c/en/windows'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[windows]]',\n",
" 'weight': 4.814976635457331},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/drink/,/c/en/glass/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/drink',\n",
" '@type': 'Node',\n",
" 'label': 'drink',\n",
" 'language': 'en',\n",
" 'term': '/c/en/drink'},\n",
" 'surfaceText': '[[drink]] is related to [[glass]]',\n",
" 'weight': 4.302092514114498},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/sand/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/sand',\n",
" '@type': 'Node',\n",
" 'label': 'sand',\n",
" 'language': 'en',\n",
" 'term': '/c/en/sand'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[sand]]',\n",
" 'weight': 4.262393693689028},\n",
" {'@id': '/a/[/r/RelatedTo/,/c/en/glass/,/c/en/cup/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/verbosity',\n",
" 'end': {'@id': '/c/en/cup',\n",
" '@type': 'Node',\n",
" 'label': 'cup',\n",
" 'language': 'en',\n",
" 'term': '/c/en/cup'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/RelatedTo',\n",
" '@type': 'Relation',\n",
" 'label': 'RelatedTo'},\n",
" 'sources': [{'@id': '/and/[/s/process/split_words/,/s/resource/verbosity/]',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity',\n",
" 'process': '/s/process/split_words'},\n",
" {'@id': '/s/resource/verbosity',\n",
" '@type': 'Source',\n",
" 'contributor': '/s/resource/verbosity'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is related to [[cup]]',\n",
" 'weight': 4.134247210799083},\n",
" {'@id': '/a/[/r/AtLocation/,/c/en/glass/,/c/en/cabinet/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/cabinet',\n",
" '@type': 'Node',\n",
" 'label': 'the cabinet',\n",
" 'language': 'en',\n",
" 'term': '/c/en/cabinet'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/AtLocation',\n",
" '@type': 'Relation',\n",
" 'label': 'AtLocation'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/cffrost/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/cffrost'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/logicexecution/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/logicexecution'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/sabaki/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/sabaki'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/jdkcubed/]',\n",
" '@type': 'Source',\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/jdkcubed'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/mycorner/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/mycorner'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'a glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': 'You are likely to find [[a glass]] in [[the '\n",
" 'cabinet]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/AtLocation/,/c/en/water/,/c/en/glass/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'a glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/AtLocation',\n",
" '@type': 'Relation',\n",
" 'label': 'AtLocation'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/narcisse/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/narcisse'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/ovan4/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/ovan4'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/annedog/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/annedog'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/dragonjools/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/dragonjools'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/ovan4/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/ovan4'}],\n",
" 'start': {'@id': '/c/en/water',\n",
" '@type': 'Node',\n",
" 'label': 'water',\n",
" 'language': 'en',\n",
" 'term': '/c/en/water'},\n",
" 'surfaceText': 'You are likely to find [[water]] in [[a glass]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/CapableOf/,/c/en/glass/,/c/en/break_easily/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/break_easily',\n",
" '@type': 'Node',\n",
" 'label': 'break easily',\n",
" 'language': 'en',\n",
" 'term': '/c/en/break_easily'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/CapableOf',\n",
" '@type': 'Relation',\n",
" 'label': 'CapableOf'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/suzanne/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/suzanne'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/bagsc/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/bagsc'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/cfalz/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/cfalz'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/kcalder/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/kcalder'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/slux/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/slux'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] can [[break easily]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/HasProperty/,/c/en/glass/,/c/en/clear/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/clear',\n",
" '@type': 'Node',\n",
" 'label': 'clear',\n",
" 'language': 'en',\n",
" 'term': '/c/en/clear'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/HasProperty',\n",
" '@type': 'Relation',\n",
" 'label': 'HasProperty'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/dallsopp/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/dallsopp'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/halelaniau/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/halelaniau'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/dallsopp/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/dallsopp'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/kemcmanus/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/kemcmanus'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/mleaf/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/mleaf'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[glass]] is [[clear]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/HasProperty/,/c/en/glass/,/c/en/recyclable/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/recyclable',\n",
" '@type': 'Node',\n",
" 'label': 'recyclable',\n",
" 'language': 'en',\n",
" 'term': '/c/en/recyclable'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/HasProperty',\n",
" '@type': 'Relation',\n",
" 'label': 'HasProperty'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/schueler/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/schueler'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/browni/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/browni'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/laserjoy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/laserjoy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/phraughy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/phraughy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/secrgb/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/secrgb'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'Glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[Glass]] is [[recyclable]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/ReceivesAction/,/c/en/glass/,/c/en/recycled/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/recycled',\n",
" '@type': 'Node',\n",
" 'label': 'recycled',\n",
" 'language': 'en',\n",
" 'term': '/c/en/recycled'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/ReceivesAction',\n",
" '@type': 'Relation',\n",
" 'label': 'ReceivesAction'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/laserjoy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/laserjoy'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/phraughy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/phraughy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/browni/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/browni'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/phraughy/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/phraughy'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/schueler/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/schueler'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'Glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[Glass]] can be [[recycled]]',\n",
" 'weight': 4.0},\n",
" {'@id': '/a/[/r/UsedFor/,/c/en/glass/,/c/en/holding_liquid/]',\n",
" '@type': 'Edge',\n",
" 'dataset': '/d/conceptnet/4/en',\n",
" 'end': {'@id': '/c/en/holding_liquid',\n",
" '@type': 'Node',\n",
" 'label': 'holding liquid',\n",
" 'language': 'en',\n",
" 'term': '/c/en/holding_liquid'},\n",
" 'license': 'cc:by/4.0',\n",
" 'rel': {'@id': '/r/UsedFor',\n",
" '@type': 'Relation',\n",
" 'label': 'UsedFor'},\n",
" 'sources': [{'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/discostu/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/discostu'},\n",
" {'@id': '/and/[/s/activity/omcs/omcs1_possibly_free_text/,/s/contributor/omcs/stormhunter/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/omcs1_possibly_free_text',\n",
" 'contributor': '/s/contributor/omcs/stormhunter'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/bdaniels/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/bdaniels'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/justjim/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/justjim'},\n",
" {'@id': '/and/[/s/activity/omcs/vote/,/s/contributor/omcs/stormhunter/]',\n",
" '@type': 'Source',\n",
" 'activity': '/s/activity/omcs/vote',\n",
" 'contributor': '/s/contributor/omcs/stormhunter'}],\n",
" 'start': {'@id': '/c/en/glass',\n",
" '@type': 'Node',\n",
" 'label': 'a glass',\n",
" 'language': 'en',\n",
" 'term': '/c/en/glass'},\n",
" 'surfaceText': '[[a glass]] is for [[holding liquid]]',\n",
" 'weight': 4.0}],\n",
" 'view': {'@id': '/c/en/glass?offset=0&limit=20',\n",
" '@type': 'PartialCollectionView',\n",
" 'comment': \"There are more results. Follow the 'nextPage' link for \"\n",
" 'more.',\n",
" 'firstPage': '/c/en/glass?offset=0&limit=20',\n",
" 'nextPage': '/c/en/glass?offset=20&limit=20',\n",
" 'paginatedProperty': 'edges'}}\n"
]
}
],
"source": [
"searchword = \"glass\"\n",
"search_url = \"http://api.conceptnet.io/c/en/\"+searchword\n",
"print(search_url)\n",
"r = requests.get(search_url)\n",
"data = r.json()\n",
"pprint(data) #pretty print!!!"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"drinking\n",
"holding liquid\n"
]
}
],
"source": [
"for edge in data[\"edges\"]:\n",
" if edge[\"rel\"][\"label\"] == \"UsedFor\":\n",
" print(edge[\"end\"][\"label\"]) \n",
"#but the results are limited up to 20 by default"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"drinking\n",
"holding liquid\n",
"seeing through\n",
"drinking from\n",
"drinking liquid from\n",
"drinking out of\n",
"hold\n"
]
}
],
"source": [
"search_url = \"http://api.conceptnet.io/c/en/glass?rel=/r/UsedFor&limit=1000\"\n",
"r = requests.get(search_url)\n",
"data = r.json()\n",
"offset = 0\n",
"search_url = \"http://api.conceptnet.io/c/en/glass?rel=/r/UsedFor&limit=1000?offset=\"+str(offset)\n",
"r = requests.get(search_url)\n",
"for edge in data[\"edges\"]:\n",
" print(edge[\"end\"][\"label\"]) if edge[\"rel\"][\"label\"]==\"UsedFor\" else \"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment