首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解CS 505编程、辅导CS,Java程序、Python编程辅导 讲解留学生Processing|讲解SPSS
项目预算:
开发周期:
发布时间:
要求地区:
CS 505 – Spring 2021 – Assignment 2 (100 pts, bonus: 10 pts) – Scraping, Text Processing, LM, Analysis
Problems due 11:59PM EST, February 26.
In this assignment, you will learn all about scraping, pre-processing, and conducting preliminary analysis of text,
which are very important when doing NLP, and use python libraries such as NLTK, spacy, which are popular in NLP.
You have 2 weeks to finish this particular assignment.
Submit in Blackboard by 11:59PM EST, February 26.
–Please indicate names of those you collaborate with.
–Every late day will reduce your score by 20
–After 2 days (i.e., if you submit on the 3rd day after due date), it will be marked 0.
Submit your (1) code, (2) README.txt containing the instruction to run your code, (3) extracted data
(tweets’ json, Wikipedia text, and news text), and (4) write up in one zip file.
When necessary, you must show how you derive your answer
Problem 1. (15 pts) In online discussion forums, such as Reddit, discussions are broken down into different communities.
Given such forum:
1. (5 pts) How do you determine which community a post is likely from in an unsupervised manner?
2. (5 pts) How can you automatically generate posts that will fit a particular community?
3. (5 pts) If there is a debate inside a particular community regarding a specific topic, say COVID-19, and
given that the points of contentions come from this list: mask wearing, reopening, vaccination; how do you
determine which stance a person is taking in a post about COVID-19?
For each of the task above, please specify what type of model you can use to address the task and identify what would
be the training data, features, and labels (if any), and what would be the output of the model.
Problem 2. (5 pts) Use maximum likelihood estimate to derive unigram P(wi), bigram P(wi|wi−1), trigram
P(wi|wi−1, wi−2) probabilities i.e., slide 16 in Language Model lecture.
Problem 3. (5 pts) In the Language Model lecture (slide 35), we derive the formulation of perplexity of a single test
sentence. Derive the formulation of perplexity for the whole test set containing k sentences for a trigram language
model.
Problem 4. (25 pts, bonus: 10 pts) Twitter Scraping. Use your Twitter Developer API to scrape 10,000 most recent
tweets in the English language from Twitter with the keyword ’covid’. You can use the search function of library
such as Twython. Out of these 10,000 tweets, use 9,000 to train a unigram, bigram, and trigram language models
(LMs). Use NLTK library with KneserNeyInterpolated language model (currently possibly the best for smoothing)
to build your LMs to deal with zero-count ngrams. Remember to process the text first before using it to train your
LMs i.e., sentence segmenting, tokenizing, lower casing, and padding with begin-of-sentence and end-of-sentence
symbols (all of these can be done within NLTK). Use the same pre-processing on your test text.
1
1. (9 pts) Report the average perplexities of your language models on the remaining 1,000 tweets i.e., use NLTK
LM perplexity function to compute the perplexity of each tweet, and then average.
Note that NLTK is implementing perplexity slightly differently than what we discuss in class with regards to
normalizing, it normalizes based on the number of ngrams instead of the length of the sentence—you should
see the source code of NLTK to find out more.
2. (6 pts) Generate 10 tweets using each of your language model (for a total of 30 tweets). For each language
model, mention interesting observation from its generated tweets e.g., are they coherent? do the tweets reflect
interesting topics?
3. (10 pts, bonus: 10 pts) Using NLTK library (with VADER, which is a lexicon and rule-based sentiment analysis
model), compute the sentiment of each tweet in all your 10,000 tweets.
(a) (4 pts) What is the average compound sentiment of the tweets from VADER? Are users in your collected
tweets generally positive/neutral/negative when talking about COVID-19?
(b) (6 pts) After removing stopwords using NLTK, for positive tweets, what are the top 10 words mentioned?
and for negative tweets, what are the top 10 words mentioned?
(c) (Bonus 10 pts) Using only tweets that are geo-located with country code US i.e., has non-null child
object place in its json, extract the state information from the full name child object of place. Report
average sentiment compound scores from each of the state you found. Which state in your data has the
most positive users, which state has the most negative users?
Problem 5. (30 pts) Wikipedia Scraping. Use library such as requests to scrape HTML of this page in Wikipedia:
https://en.wikipedia.org/wiki/COVID-19 pandemic and scrape also the HTML of pages within Wikipedia that are
linked from this page—you will have to look at the retrieved HTML of the first page and see the pattern you can
use to obtain links from this page to other Wikipedia pages. Once you retrieve all the pages, using library such as
BeautifulSoup or regular expressions of your creation, extract only the text of the pages.
1. (10 pts) Sentence split, tokenize, lemmatize, lower case, then remove stop words from the text using the library
spacy. Then, construct a vocabulary of words in the text.
(a) (5 pts) What are the top 20 words in the vocabulary according to frequency? Are they from a specific
topic? Do they give you insights into what the text is all about?
(b) (5 pts) Using library such as wordcloud, generate the word cloud of the text to visualize the distribution of
words—include the word cloud image in your write up. Does the word cloud give you some insights into
what the text is all about?
2. (10 pts) Sentence split, tokenize, lemmatize, lower case, then remove stop words from your 1,000 test tweets
from Problem 4 using spacy.
(a) (2 pts) Compute how many word types in your tweets are out-of-vocabulary, normalized by the number of
word types in your tweets, when using vocabulary constructed from Wikipedia above.
(b) (2 pts) Compute how many tokens in your tweets are out of vocabulary, normalized by the number of
tokens in your tweets. This is the OOV-rate of your tweet test set.
(c) (4 pts) Compute the OOV-rate of your tweet test set when using your 9,000 train tweets from Problem 4
to construct your vocabulary/lexicon. Note that you have to do the same pre-processing on your tweet
train set (i.e., sentence split, tokenize, lemmatize, lower case, then remove stop words using spacy) before
constructing the vocabulary.
(d) (2 pts) What does the OOV-rate tell you about the domain of these two texts (Wikipedia vs. Twitter of
similar topic that is COVID-19)?
2
3. (10 pts) Sentence split, tokenize, and lower case the Wikipedia data you have collected, then get the first 9,000
sentences from the data—most of the sentences therefore will come from the first URL that you scrape:
https://en.wikipedia.org/wiki/COVID-19 pandemic. Then, train a trigram KneserNeyInterpolated language
model based on these 9,000 sentences (remember to pad with begin- and end-of-sentence symbols).
(a) (5 pts) Report the average perplexity of the model on your Twitter test sentences, the one that contains
1,000 tweets from Problem 4 (remember to pre-process the test set the same way you pre-process the
training data of your LM).
(b) (5 pts) Compare this perplexity to the one you obtain in Problem 4.1 for the trigram LM trained on tweets.
What does the perplexity difference tell you about the domain of these two texts (Wikipedia vs. Twitter of
similar topic that is COVID-19)?
Problem 6. (20 pts) News Scraping. Scrape ABC and Fox News articles from their sitemaps. You can use this
github project:
https://github.com/pmyteh/RISJbot for scraping, or you can build your own. Extract the text of the articles, then
sentence split, tokenize, and remove stop words using spacy.
1. (10 pts) Construct type-token graph of news texts from these two news sites, where x-axis is #token, and y-axis
is #type. As the number of tokens grow, the number of word types would grow and then plateau at some point.
Include the type-token graph in your write up. Do you see interesting insights when comparing the two graphs?
2. (10 pts) Construct the word clouds from the two texts. Include the word clouds and interesting insights from
them in your write up.
3
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!