Changes to jupyter notebook for lightning talks
This commit is contained in:
parent
ddee5e4a3b
commit
d922297f99
@ -212,42 +212,14 @@
|
||||
"\n",
|
||||
"We can partition by threes too:\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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"(<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",
|
||||
"Or, the condition can be two words (`condition = 'the lazy'`):\n",
|
||||
"\n",
|
||||
"(The quick brown) (quick brown fox) ... (<span style=\"color:blue\">the lazy</span> <span span=\"color:red\">dog</span>)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"(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",
|
||||
"\n",
|
||||
"These are **trigrams**."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"We can partition any **N** number of words together as **ngrams**."
|
||||
]
|
||||
},
|
||||
@ -343,7 +315,7 @@
|
||||
"source": [
|
||||
"words = ('The quick brown fox jumped over the '\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()}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"## Conditional Frequency Distributions (CFDs) ##"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
@ -501,9 +484,9 @@
|
||||
"word = random.choice(TEXT)\n",
|
||||
"# generate 15 more words\n",
|
||||
"for i in range(15):\n",
|
||||
" print word,\n",
|
||||
" print(word + ' ', end='')\n",
|
||||
" if word in cfd:\n",
|
||||
" word = random.choice(cfd[word].keys())\n",
|
||||
" word = random.choice(list(cfd[word].keys()))\n",
|
||||
" else:\n",
|
||||
" break"
|
||||
]
|
||||
@ -604,10 +587,12 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Syllables\n",
|
||||
"\n",
|
||||
"* poet: /ˈpoʊət/\n",
|
||||
"* does: /ˈdʌz/\n",
|
||||
"\n",
|
||||
@ -806,7 +791,7 @@
|
||||
"source": [
|
||||
"from stat_parser import Parser\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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"metadata": {
|
||||
@ -962,6 +959,20 @@
|
||||
"[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",
|
||||
"metadata": {
|
||||
@ -973,28 +984,30 @@
|
||||
"source": [
|
||||
"# The end #\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": {
|
||||
"celltoolbar": "Slideshow",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.12"
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.2"
|
||||
},
|
||||
"livereveal": {
|
||||
"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