Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjun committed Apr 2, 2019
1 parent a693c94 commit 584a3fe
Show file tree
Hide file tree
Showing 9 changed files with 4,281 additions and 819 deletions.
Binary file modified code/.DS_Store
Binary file not shown.
127 changes: 6 additions & 121 deletions code/0.common_questions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@
"\n",
"https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/\n",
"\n",
"> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ \n",
" \n",
"```python\n",
"conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/\n",
"conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/\n",
"conda config --set show_channel_urls yes\n",
"```\n",
"\n",
"#### 设置搜索时显示通道地址 \n",
"> conda config --set show_channel_urls yes \n",
"\n",
Expand Down Expand Up @@ -369,125 +373,6 @@
"pandoc infile.md -o outfile.pdf --latex-engine=xelatex -V mainfont=\"SimSun\""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# 安装twitter_text\n",
"> ## <del>pip install twitter-text-py</de> \n",
"\n",
"[twitter-text-py](https://github.com/dryan/twitter-text-py/issues/21) could not be used for python 3, I debug the problem, and make [a new repo of twitter-text-py3](https://github.com/computational-class/twitter-text-py3).\n",
"\n",
"\n",
"> ## pip install git+https://github.com/computational-class/twitter-text-py3.git"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['AnonKitsu', 'chengjun', 'mili'] ['http://computational-communication.com', 'http://ccc.nju.edu.cn'] ['OCCUPYWALLSTREET', 'OWS', 'OCCUPYNY'] -------->\n"
]
}
],
"source": [
"import twitter_text\n",
"\n",
"tweet = '''RT @AnonKitsu: ALERT!!!!!!!!!!COPS ARE KETTLING PROTESTERS IN PARK W HELICOPTERS AND PADDYWAGONS!!!! \n",
" #OCCUPYWALLSTREET #OWS #OCCUPYNY PLEASE @chengjun @mili http://computational-communication.com \n",
" http://ccc.nju.edu.cn RT !!HELP!!!!'''\n",
"\n",
"ex = twitter_text.Extractor(tweet)\n",
"at_names = ex.extract_mentioned_screen_names()\n",
"urls = ex.extract_urls()\n",
"hashtags = ex.extract_hashtags()\n",
"print(at_names, urls, hashtags,'-------->')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on package twitter_text:\n",
"\n",
"NAME\n",
" twitter_text - # encoding=utf-8\n",
"\n",
"PACKAGE CONTENTS\n",
" autolink\n",
" extractor\n",
" highlighter\n",
" regex\n",
" templatetags (package)\n",
" unicode\n",
" validation\n",
"\n",
"CLASSES\n",
" builtins.object\n",
" TwitterText\n",
" \n",
" class TwitterText(builtins.object)\n",
" | Methods defined here:\n",
" | \n",
" | __init__(self, text)\n",
" | Initialize self. See help(type(self)) for accurate signature.\n",
" | \n",
" | __repr__(self)\n",
" | Return repr(self).\n",
" | \n",
" | __unicode__(self)\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors defined here:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
" | \n",
" | autolink\n",
" | \n",
" | extractor\n",
" | \n",
" | highlighter\n",
" | \n",
" | validation\n",
"\n",
"FILE\n",
" /Users/datalab/Applications/anaconda/lib/python3.5/site-packages/twitter_text/__init__.py\n",
"\n",
"\n"
]
}
],
"source": [
"import twitter_text\n",
"help(twitter_text)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
108 changes: 63 additions & 45 deletions code/03.graphlab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,31 +204,46 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 20,
"metadata": {
"ExecuteTime": {
"end_time": "2017-05-13T09:39:05.313045",
"start_time": "2017-05-13T09:38:57.997451"
},
"slideshow": {
"slide_type": "slide"
"end_time": "2019-01-13T03:43:40.567561Z",
"start_time": "2019-01-13T03:43:40.309959Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This non-commercial license of GraphLab Create for academic use is assigned to [email protected] and will expire on March 14, 2019.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO] graphlab.cython.cy_server: GraphLab Create v2.1 started. Logging: /tmp/graphlab_server_1522132034.log\n"
"ename": "ImportError",
"evalue": "No module named turicreate",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-20-5ead07cb1a22>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mturicreate\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mtc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Load data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'photoLabel.sframe'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: No module named turicreate"
]
}
],
"source": [
"import turicreate as tc\n",
"\n",
"# Load data \n",
"data = tc.SFrame('photoLabel.sframe')"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2019-01-13T03:41:00.956397Z",
"start_time": "2019-01-13T03:41:00.888861Z"
},
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
Expand All @@ -250,11 +265,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 18,
"metadata": {
"ExecuteTime": {
"end_time": "2017-05-13T09:39:05.313045",
"start_time": "2017-05-13T09:38:57.997451"
"end_time": "2019-01-13T03:42:32.134047Z",
"start_time": "2019-01-13T03:42:32.047306Z"
},
"slideshow": {
"slide_type": "slide"
Expand All @@ -265,21 +280,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"This non-commercial license of GraphLab Create for academic use is assigned to [email protected] and will expire on May 12, 2018.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2017-05-13 09:39:05,184 [INFO] graphlab.cython.cy_server, 176: GraphLab Create v1.8.5 started. Logging: /tmp/graphlab_server_1494639542.log\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"SGraph({'num_edges': 1, 'num_vertices': 3})\n"
"SGraph({'num_edges': 3, 'num_vertices': 3})\n"
]
}
],
Expand All @@ -291,20 +292,26 @@
" Vertex(2, attr={'breed': 'vizsla'})]\n",
"g = g.add_vertices(verts)\n",
"g = g.add_edges(Edge(1, 2))\n",
"g = g.add_edges([Edge(0, 2), Edge(0, 1)])\n",
"\n",
"print g"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2019-01-13T03:42:33.036185Z",
"start_time": "2019-01-13T03:42:33.030689Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Canvas is accessible via web browser at the URL: http://localhost:53086/index.html\n",
"Opening Canvas in default web browser.\n"
"Canvas is updated and available in a tab in the default browser.\n"
]
}
],
Expand Down Expand Up @@ -541,28 +548,39 @@
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python [conda env:anaconda]",
"display_name": "Python 2",
"language": "python",
"name": "conda-env-anaconda-py"
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"pygments_lexer": "ipython2",
"version": "2.7.14"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
"eqNumInitial": 0,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
Expand Down
Loading

0 comments on commit 584a3fe

Please sign in to comment.