当前位置:天才代写 > haskell代写 > Haskell代写英文coursework代做题目:Portfolio element – Haskell

Haskell代写英文coursework代做题目:Portfolio element – Haskell

2018-01-06 08:00 星期六 所属: haskell代写 浏览:713

   Portfolio element – Haskell

 


 

Portfolio element – Haskell

Unit

Programming languages: principles and design (6G6Z1110)

Programming languages – SE frameworks (6G6Z1115)

Lecturer

Dr Ivan Olier

Week

11

Portfolio element

Haskell (15% of coursework)

Introduction

 

Figure 1 shows the “main” function of a Haskell program that reads a plain text file whose name is asked to the user, and reports:

 

1) The total number of words in the text.

 

2) The total number of the top 20 most commonly used English words that appears in the text according to the Oxford English Corpus (OEC) rank. See the list in Figure 2.

3) A histogram of the top 20 most frequent words in the text excluding common words.

 

Figure 3 shows an example of the program execution. The plain text file (text_sample.txt) used for this example is available on Moodle. You should use it to check the output of your implementation matches the one shown in the figure.

 

image.png

Figure 1. “main” function of the program (file available on Moodle)

 

 

the

and

have

not

as

be

a

I

on

you

to

in

it

with

do

of

that

for

he

at

   Figure 2. List of the top 20 most frequently used words in English according to the OEC rank.

 

Assignment

 

You must complete the program shown in Figure 1 by implementing the missing functions. Your complete program should execute as shown in Figure 3. Table 1 shows the list of missing functions you should implement, along with brief descriptions and examples of use. You can use those examples to test the output of your functions on GHCi before you add them to your program.

 

You may need to implement additional functions, but your program must contain the implementation of the functions listed on Table 1, at least. Modifications of the “do” block (Figure 1) are not permitted.


 

 

 

6G6Z1110 & 6G6Z1115, Dr Ivan Olier


   Portfolio element – Haskell

 image.png

Figure 3. Example of the program execution

 

 

Table 1. List of the missing functions that must be implemented

 

Function name

Brief description

Function call example

toWordList

Takes a string, lowercases it,

> toWordList "Hello, World! HELLO!! :-)"

drops  any  character  that  is

["hello","hello","world"]

not a letter, and returns a list

with the words in the string.

countCommonWords

Takes  a  list  of  strings  and

> countCommonWords ["the","planet","of","the","apes"]

returns the number of times

3

the 20 most frequently used

English words appears in the

list.

dropCommonWords

Takes  a  list  of  strings  and

> dropCommonWords ["the","planet","of","the","apes"]

drops any word that is within

["planet","apes"]

the  top  20  most  commonly

used  in  English.  Returns  a

list  of  strings  without  those

words.

countWords

Takes  a  list  of  strings  and

> countWords ["friend","she","she"]

returns  a  list.  Each  element

[("friend",1),("she",2)]

of the returned list is a tuple

which  contains  a  string  (a

word)and

aninteger

(representing

the  number  of

times the word appears in the

text).


 

 

6G6Z1110 & 6G6Z1115, Dr Ivan Olier


   Portfolio element – Haskell

 

 

sortWords

It

sorts

words

by

their

> sortWords [("friend",1),("she",2)]

frequency

in

descending

[("she",2),("friend",1)]

order. It takes and returns a

list  of  tuples.  Each  element

of the tuple consists of one

string  (the  word)  and  one

integer (its frequency).

makeHistogram

Makes

a

histogram

using

> makeHistogram [("her",4),("she",2),("friend",1)]

asterisks.

It

takes

a

list

of

"**** -> her\n** -> she\n* -> friend\n"

tuples

(string,

integer)

and

returns

a

string

which

contains

the

histogram.

It

also

contains

the

required

line breaks (“\n”) such that it

should print the histogram as

shown  in  Figure  3  when

using

a

function

like

putStr” (see last code line,

Figure 1).

 

Submission

 

You must submit through Moodle a unique file named “assignment.hs” which contains the complete program including the implementation of the missing functions listed in Table 1, the code in Figure 1 without any modification, and any additional function you needed to implement in order for your program to be fully functional (as shown in Figure 2). Submission link is available in Week 11 section on Moodle.

 

 

Hint

 

You may find useful the following Haskell functions. You might not need some of them, or you might require additional ones:

 

sort
 
words

   take

 

map
 
replicate
   filter

 

sortby
 
head

   concat

 

6G6Z1110 & 6G6Z1115, Dr Ivan Olier

代写计算机编程类/金融/高数/论文/英文


  u=199783060,2774173244&fm=58&s=188FA15AB1206D1108400056000040F6&bpow=121&bpoh=75.jpgalipay_pay_96px_533896_easyicon.net.pngpaypal_96px_533937_easyicon.net.pngchina_union_pay_96px_533911_easyicon.net.pngmastercard_pay_96px_533931_easyicon.net.pngasia_pay_96px_533902_easyicon.net.png

本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝或者Upwork交易!

E-mail:850190831@qq.com   微信:BadGeniuscs  工作时间:无休息工作日-早上8点到凌晨3点


如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

qr.png

 

天才代写-代写联系方式