Skip to content

Commit

Permalink
Merge pull request fastai#214 from bharadwaj6/master
Browse files Browse the repository at this point in the history
fix spacy tokenizer import in lesson 4
  • Loading branch information
jph00 authored Mar 20, 2018
2 parents 0b09e4e + 13cb31c commit bcd7e48
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions courses/dl1/lesson4-imdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"from fastai.nlp import *\n",
"from fastai.lm_rnn import *\n",
"\n",
"import dill as pickle"
"import dill as pickle\n",
"import spacy"
]
},
{
Expand Down Expand Up @@ -64,7 +65,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"aclImdb_v1.tar.gz imdbEr.txt imdb.vocab \u001b[0m\u001b[01;34mmodels\u001b[0m/ README \u001b[01;34mtest\u001b[0m/ \u001b[01;34mtmp\u001b[0m/ \u001b[01;34mtrain\u001b[0m/\r\n"
"imdbEr.txt imdb.vocab README \u001b[0m\u001b[01;34mtest\u001b[0m/ \u001b[01;34mtrain\u001b[0m/\r\n"
]
}
],
Expand Down Expand Up @@ -198,20 +199,29 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"spacy_tok = spacy.load('en')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"I have to say when a name like Zombiegeddon and an atom bomb on the front cover I was expecting a flat out chop - socky fung - ku , but what I got instead was a comedy . So , it was n't quite was I was expecting , but I really liked it anyway ! The best scene ever was the main cop dude pulling those kids over and pulling a Bad Lieutenant on them ! ! I was laughing my ass off . I mean , the cops were just so bad ! And when I say bad , I mean The Shield Vic Macky bad . But unlike that show I was laughing when they shot people and smoked dope . \\n\\n Felissa Rose ... man , oh man . What can you say about that hottie . She was great and put those other actresses to shame . She should work more often ! ! ! ! ! I also really liked the fight scene outside of the building . That was done really well . Lots of fighting and people getting their heads banged up . FUN ! Last , but not least Joe Estevez and William Smith were great as the ... well , I was n't sure what they were , but they seemed to be having fun and throwing out lines . I mean , some of it did n't make sense with the rest of the flick , but who cares when you 're laughing so hard ! All in all the film was n't the greatest thing since sliced bread , but I was n't expecting that . It was a Troma flick so I figured it would totally suck . It 's nice when something surprises you but not totally sucking . \\n\\n Rent it if you want to get stoned on a Friday night and laugh with your buddies . Do n't rent it if you are an uptight weenie or want a zombie movie with lots of flesh eating . \\n\\n P.S. Uwe Boil was a nice touch .\""
"\"I have to say when a name like Zombiegeddon and an atom bomb on the front cover I was expecting a flat out chop - socky fung - ku , but what I got instead was a comedy . So , it was n't quite was I was expecting , but I really liked it anyway ! The best scene ever was the main cop dude pulling those kids over and pulling a Bad Lieutenant on them ! ! I was laughing my ass off . I mean , the cops were just so bad ! And when I say bad , I mean The Shield Vic Macky bad . But unlike that show I was laughing when they shot people and smoked dope.<br /><br />Felissa Rose ... man , oh man . What can you say about that hottie . She was great and put those other actresses to shame . She should work more often ! ! ! ! ! I also really liked the fight scene outside of the building . That was done really well . Lots of fighting and people getting their heads banged up . FUN ! Last , but not least Joe Estevez and William Smith were great as the ... well , I was n't sure what they were , but they seemed to be having fun and throwing out lines . I mean , some of it did n't make sense with the rest of the flick , but who cares when you 're laughing so hard ! All in all the film was n't the greatest thing since sliced bread , but I was n't expecting that . It was a Troma flick so I figured it would totally suck . It 's nice when something surprises you but not totally sucking.<br /><br />Rent it if you want to get stoned on a Friday night and laugh with your buddies . Do n't rent it if you are an uptight weenie or want a zombie movie with lots of flesh eating.<br /><br />P.S. Uwe Boil was a nice touch .\""
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"' '.join(spacy_tok(review[0]))"
"' '.join([sent.string.strip() for sent in spacy_tok(review[0])])"
]
},
{
Expand All @@ -225,13 +235,11 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"TEXT = data.Field(lower=True, tokenize=spacy_tok)"
"TEXT = data.Field(lower=True, tokenize=\"spacy\")"
]
},
{
Expand Down

0 comments on commit bcd7e48

Please sign in to comment.