Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions week2/week2-NER.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,32 @@
" \n",
" tweet_tokens = []\n",
" tweet_tags = []\n",
" for line in open(file_path, encoding='utf-8'):\n",
" line = line.strip()\n",
" if not line:\n",
" with open(file_path, encoding='utf-8') as fin:\n",
" for line in fin:\n",
" line = line.strip()\n",
" if not line:\n",
" if tweet_tokens:\n",
" tokens.append(tweet_tokens)\n",
" tags.append(tweet_tags)\n",
" tweet_tokens = []\n",
" tweet_tags = []\n",
" else:\n",
" token, tag = line.split()\n",
" # Replace all urls with <URL> token\n",
" # Replace all users with <USR> token\n",
"\n",
" ######################################\n",
" ######### YOUR CODE HERE #############\n",
" ######################################\n",
"\n",
" tweet_tokens.append(token)\n",
" tweet_tags.append(tag)\n",
" else:\n",
" if tweet_tokens:\n",
" tokens.append(tweet_tokens)\n",
" tags.append(tweet_tags)\n",
" tweet_tokens = []\n",
" tweet_tags = []\n",
" else:\n",
" token, tag = line.split()\n",
" # Replace all urls with <URL> token\n",
" # Replace all users with <USR> token\n",
"\n",
" ######################################\n",
" ######### YOUR CODE HERE #############\n",
" ######################################\n",
" \n",
" tweet_tokens.append(token)\n",
" tweet_tags.append(tag)\n",
" \n",
" tweet_tags = [] \n",
" return tokens, tags"
]
},
Expand Down Expand Up @@ -928,7 +934,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.7.2"
}
},
"nbformat": 4,
Expand Down