首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
program程序辅导、Java编程设计调试、讲解Java 讲解R语言编程|解析Haskell程序
项目预算:
开发周期:
发布时间:
要求地区:
Lab 11: Natural Language Processing
This lab is bonus and is not required.
Goals for this lab:
Use HashMaps to quickly store and access data
Use HashSets to maintain a duplicate free collection of data
Determine the term frequency of words in a file
Prevent stopwords from being included in the term frequency
Write, compile, and execute Java programs using the given instructions
General Guidelines:
Use meaningful variable names
Use appropriate indentation
Use comments, especially for the header, variables, and blocks of code.
Example Header:
Date:
Instructor:
Description: A small description in your own words
that describe what the program does. Any
additional flags needed to allow the
program to compile should also be placed
here.
*/
1. Term Frequency
The area of natural language processing is typically an intersection between linguistics, computer science, and
artificial intelligence. Algorithms and software are developed in order to allow the computer to infer meaning
and make decisions based on human languages. This could be as complex as teaching a computer to carry on a
reasonable conversation with a human, or as “simple” as trying to determine if people liked a movie based on
their social media posts. In both cases, sentences must be broken down into individual words or phrases so
that the computer can process them. One of the first steps is often term frequency analyses, where the
frequency of words are counted, so that the most important or significant words can be determined.
For this exercise you will be writing a program to count the number of words in chunk of text. The input file
will contain multiple lines, and punctuation has already been removed, however not all of the words are
completely lowercase. You will need to break up each line into individual words, and maintain a count of how
many times each word appears in the overall text chunk using a HashMap. Finally, you will need to output the
list of words and their frequencies to the user
To complete this program:
In a file named FreqCountV1.java, define a class named FreqCountV1 which will perform the text
analysis. The class should contain:
o A private, static method named readTextFile, which takes in a HashMap and returns
nothing and should:
Prompt the user for the name of the file containing the text, and repeatedly reprompt
the user if the filename they enter does not exist
Read in the file one word at a time and for each word
Convert it to all lowercase letters
If the word already exists in the HashMap, increase its count by one in the
HashMap
Otherwise, add it to the HashMap and set its count to one
o A private, static method named outputFreq, which takes in a HashMap and returns nothing
and should:
Output each word and its associated count from the HashMap
Because words are different lengths, make sure that you determine the length of the
longest word and use that in your formatting to produce a cleaner output (see
outputV1.txt)
o A main method, which should:
Contain a HashMap that indexes counts using Strings
Call readTextFile using the HashMap
Call outputFreq using the HashMap
Complete the program, making sure to compile and run it to verify that it produces the correct results. Note
that you will submit the FreqCountV1.java file to Canvas.
2. Stopwords
One of the initial challenges facing proper term frequency analysis is the occurrence of stopwords, or words
that provide little to no information regarding the text. These are typically common words such as “the”, “a”,
“and”, “have”, or single letters. Thus, to focus on the more important words, we want to perform stopword
removal (or at least prevent their inclusion) in our analysis.
For this exercise you will be improving upon your previous code from part 1 of this lab. You will perform all of
the same steps from last time, but before you read in the text file, you will need to read in a list of stopwords
and store them in a HashSet. Then, as you are reading in your text file, use the HashSet to prevent the
adding of stopwords to the HashMap containing your term frequencies.
To complete this program:
In a file named FreqCountV2.java, define a class named FreqCountV2 which will perform the text
analysis. The class should contain:
o A private, static method named readStopWordsFile, which takes in a HashSet and
returns nothing and should:
Prompt the user for the name of the file containing the list of stopwords, and repeatedly
reprompt the user if the filename they enter does not exist
Read in the file one word at a time and for each word add it to the HashSet
o A private, static method named readTextFile, which takes in a HashMap, a HashSet,
and returns nothing and should:
Prompt the user for the name of the file containing the text, and repeatedly reprompt
the user if the filename they enter does not exist
Read in the file one word at a time and for each word
Convert it to all lowercase letters
If the word exists in the HashSet, ignore it and do not add it to the HashMap
If the word already exists in the HashMap, increase its count by one in the
HashMap
Otherwise, add it to the HashMap and set its count to one
o A private, static method named outputFreq, which takes in a HashMap and returns nothing
and should:
Output each word and its associated count from the HashMap
Because words are different lengths, make sure that you determine the length of the
longest word and use that in your formatting to produce a cleaner output (see
outputV2.txt)
o A main method, which should:
Contain a HashMap that indexes counts using Strings
Contain a HashSet that stores stopwords as Strings
Call readStopWordsFile using the HashSet
Call readTextFile using the HashMap and HashSet
Call outputFreq using the HashMap
Complete the program, making sure to compile and run it to verify that it produces the correct results. Note
that you will submit the FreqCountV2.java file to Canvas.
Submission
Once you have completed this lab it is time to turn in your work. Please submit the following files to the Lab
11 assignment in Canvas:
FreqCountV1.java
FreqCountV2.java
After you have submitted your files, you are welcome to practice some additional coding.
Rubric
Part 1 60 pts:
5 points: Program compiles successfully
20 points: Correctly implementing the readTextFile method
o 5 points for obtaining the filename from the user and opening the file
o 5 points for converting all words to all lowercase letters
o 5 points for increasing a words frequency count if it does exist
o 5 points for adding the word and setting its frequency count to one if it does not exist
20 points: Correctly implementing the outputFreq method
o 5 points for correctly outputting all of the words in the text file
o 10 points for correctly outputting all of the word frequencies in the text file
o 5 points outputting all of the words and their frequencies with proper formatting (See
outputV1.txt)
10 points: Correctly implementing the main method
o 4 points for correctly creating the HashMap
o 3 points for calling the readTextFile method with the appropriate input
o 3 points for calling the outputFreq method with the appropriate input
5 points: Appropriate commenting is included
Part 2 40 pts:
5 points: Program compiles successfully
10 points: Correctly implementing the readStopWordsFile method
o 5 points for obtaining the filename from the user and opening the file
o 5 points for adding all of the stopwords from the file to the HashSet
20 points: Correctly implementing the outputFreq method
o 5 points for correctly outputting all of the words in the text file, excluding stopwords
o 10 points for correctly outputting all of the word frequencies in the text file, excluding
stopwords
o 5 points outputting all of the words and their frequencies, excluding stopwords, with proper
formatting (See outputV2.txt)
5 points: Appropriate commenting is included
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
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
软件定制开发网!