Changes to jupyter notebook for lightning talks
This commit is contained in:
parent
ddee5e4a3b
commit
d922297f99
@ -212,42 +212,14 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"We can partition by threes too:\n",
|
"We can partition by threes too:\n",
|
||||||
"\n",
|
"\n",
|
||||||
"(<span style=\"color:blue\">The</span> <span style=\"color:red\">quick brown</span>) (quick brown fox) ... (<span style=\"color:blue\">the</span> <span style=\"color:red\">lazy dog</span>)\n"
|
"(<span style=\"color:blue\">The</span> <span style=\"color:red\">quick brown</span>) (quick brown fox) ... (<span style=\"color:blue\">the</span> <span style=\"color:red\">lazy dog</span>)\n",
|
||||||
]
|
"\n",
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"slideshow": {
|
|
||||||
"slide_type": "fragment"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"Or, the condition can be two words (`condition = 'the lazy'`):\n",
|
"Or, the condition can be two words (`condition = 'the lazy'`):\n",
|
||||||
"\n",
|
"\n",
|
||||||
"(The quick brown) (quick brown fox) ... (<span style=\"color:blue\">the lazy</span> <span span=\"color:red\">dog</span>)"
|
"(The quick brown) (quick brown fox) ... (<span style=\"color:blue\">the lazy</span> <span style=\"color:red\">dog</span>)\n",
|
||||||
]
|
"\n",
|
||||||
},
|
"These are **trigrams**.\n",
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"slideshow": {
|
|
||||||
"slide_type": "fragment"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"\n",
|
"\n",
|
||||||
"These are **trigrams**."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"slideshow": {
|
|
||||||
"slide_type": "fragment"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"We can partition any **N** number of words together as **ngrams**."
|
"We can partition any **N** number of words together as **ngrams**."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -343,7 +315,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"words = ('The quick brown fox jumped over the '\n",
|
"words = ('The quick brown fox jumped over the '\n",
|
||||||
" 'lazy dog and the quick cat').split(' ')\n",
|
" 'lazy dog and the quick cat').split(' ')\n",
|
||||||
"print words"
|
"print(words)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -409,6 +381,17 @@
|
|||||||
"{k: dict(v) for k, v in dict(cfd).items()}"
|
"{k: dict(v) for k, v in dict(cfd).items()}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"## Conditional Frequency Distributions (CFDs) ##"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -501,9 +484,9 @@
|
|||||||
"word = random.choice(TEXT)\n",
|
"word = random.choice(TEXT)\n",
|
||||||
"# generate 15 more words\n",
|
"# generate 15 more words\n",
|
||||||
"for i in range(15):\n",
|
"for i in range(15):\n",
|
||||||
" print word,\n",
|
" print(word + ' ', end='')\n",
|
||||||
" if word in cfd:\n",
|
" if word in cfd:\n",
|
||||||
" word = random.choice(cfd[word].keys())\n",
|
" word = random.choice(list(cfd[word].keys()))\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" break"
|
" break"
|
||||||
]
|
]
|
||||||
@ -604,10 +587,12 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "fragment"
|
"slide_type": "slide"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
|
"# Syllables\n",
|
||||||
|
"\n",
|
||||||
"* poet: /ˈpoʊət/\n",
|
"* poet: /ˈpoʊət/\n",
|
||||||
"* does: /ˈdʌz/\n",
|
"* does: /ˈdʌz/\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -806,7 +791,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"from stat_parser import Parser\n",
|
"from stat_parser import Parser\n",
|
||||||
"parsed = Parser().parse('The quick brown fox jumps over the lazy dog.')\n",
|
"parsed = Parser().parse('The quick brown fox jumps over the lazy dog.')\n",
|
||||||
"print parsed"
|
"print(parsed)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -917,6 +902,18 @@
|
|||||||
"[https://spacy.io/docs/api/#speed-comparison](https://spacy.io/docs/api/#speed-comparison)"
|
"[https://spacy.io/docs/api/#speed-comparison](https://spacy.io/docs/api/#speed-comparison)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"![Screenshot of displaCy, a dependency visualizer for spaCy](images/displacy.png)\n",
|
||||||
|
"[https://demos.explosion.ai/displacy/](https://demos.explosion.ai/displacy/)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -962,6 +959,20 @@
|
|||||||
"[http://karpathy.github.io/2015/05/21/rnn-effectiveness/](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)"
|
"[http://karpathy.github.io/2015/05/21/rnn-effectiveness/](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"![Screenshot of word-rnn readme on Github](images/word-rnn.png)\n",
|
||||||
|
"[word-rnn](https://github.com/larspars/word-rnn)\n",
|
||||||
|
"\n",
|
||||||
|
"[word-rnn-tensorflow](https://github.com/hunkim/word-rnn-tensorflow)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -973,28 +984,30 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# The end #\n",
|
"# The end #\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Questions?"
|
"Questions?\n",
|
||||||
|
"\n",
|
||||||
|
"Full write up at: [hallada.net/blog](http://www.hallada.net/2017/07/11/generating-random-poems-with-python.html)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"celltoolbar": "Slideshow",
|
"celltoolbar": "Slideshow",
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 2",
|
"display_name": "Python 3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python2"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 2
|
"version": 3
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "2.7.12"
|
"version": "3.5.2"
|
||||||
},
|
},
|
||||||
"livereveal": {
|
"livereveal": {
|
||||||
"scroll": true,
|
"scroll": true,
|
||||||
|
BIN
images/displacy.png
Normal file
BIN
images/displacy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
images/word-rnn.png
Normal file
BIN
images/word-rnn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 91 KiB |
Loading…
Reference in New Issue
Block a user