Write an Erlang program that counts the word frequencies in

 

Write an Erlang program that counts the word frequencies in the file assign3-part2.txt. Erlang uses a list of tuples as a hash table. Write four Erlang functions.

  1. This function has a string file name parameter and returns a list of words in the file. Open the file with file:open. The file lab3-part2.txt was written in a text editor as one line, so io:get_line will read the whole file. string:tokens will separate it into words. Its second argument specifies all the delimiters.
    • file:open(lab3-part2.txt”,read).
    • L1= io:get_line(S, '').
  2. This function has two parameters, a string word and a list of tuples, and returns a list of tuples with the word added appropriately. Each tuple is a word key and a frequency value. The lists:keyfind method will find a tuple if it exists and return false if it does not. If the word is not found use lists:append to add a tuple with the word as key and 1 as the frequency. If the word is found use lists:replace to replace the tuple with a new tuple with frequency increased by one.
  3. This function has a list of words as parameter and returns a hash table of tuples of words and their frequencies. The string:to_lower method will make a word lower case to provided the desired case insensitivity. Use the lists:foldl method to build the answer using the function 2.
  4. This function outputs the final hash table sorted by frequency from high to low using the lists:sort function. Its one parameter is the file name. It uses functions 3 and 1.

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Bill has spent 25 years as a project manager for

Bill has spent 25 years as a project manager for a large manufacturing company, but he has recently taken over the project management office for a software development company. While most of Bill’s project experience was in lean project management methodologies, he discovered that software development most often utilizes agile

Study daily 004 Topic: Theory – Practice Gap Think back

   Study daily 004 Topic: Theory – Practice Gap Think back to the beginning of the course and consider your thoughts on learning about nursing theory. Did you question the usefulness of spending a term learning about theory? Next, consider your current practice environment now that you know more about

Minoan society

Description For this assignment, you will need to look at some of the Greek myths that dealt with the Minoan society, particularly those of Daedelus, the Minotaur, Theseus, and Ariadne. You can find these if you Google for them. Be sure to stick with an appropriate site, preferably one with

150 words Social justice counselors have been described as “courageous

150 words   Social justice counselors have been described as “courageous risk-takers.” How courageous do you consider yourself to be when faced with opposition from others? Share about past professional experiences where you needed to stand up for what is right. What are some of the problems in your community,

For this Discussion, you reflect on a case from your

  For this Discussion, you reflect on a case from your past clinical experiences and consider how a patient’s pharmacokinetic and pharmacodynamic processes may alter his or her response to a drug. To Prepare Review the Resources for this module and consider the principles of pharmacokinetics and pharmacodynamics. Reflect on

Here’s the criteria for Part Four: Integrating your previous analysis

  Here’s the criteria for Part Four:  Integrating your previous analysis and comparing and contrasting the differences in financial policies (e.g., corporate investing & financing decisions) across the companies, discuss the following:(Required no of pages-1 is enough)1. Evaluate  company’s-Quest Diagnostics recent strategic actions from the financial perspective;2. Your recommendations on

These two terms used to be classified together. Discuss what

 These two terms used to be classified together.  Discuss what discoveries lead to the separation of these two groups.  Identify the technique(s) that were used to reclassify these organisms.  Discuss whether or not archaea has a role in human health and disease. Discussion Expectations:   The minimum requirements for class discussions

Suppose that you are the HR manager for a company.

 Suppose that you are the HR manager for a company. The judge in a current law suit by a former employee has ordered mandatory pre-suit mediation. Your boss is unfamiliar with mediation and she asks you to advise her as to several issues regarding the upcoming mediation. Draft a memo

1. Based on 3.3.4 “Elements”, create a Governance Approach. Your

   1. Based on 3.3.4 “Elements”, create a Governance Approach. Your stakeholder matrix and the stakeholder list will be important for this output. Besides, use 10.35 “Process Modelling” to create a graphical model to show how change requests will be processed. Consider having another team member in your team manage

In a 6-8 page research, explore a social issue or

  In a 6-8 page research, explore a social issue or problem affecting a marginalized group in the US and a solution or resolution to alleviate this problem. Be sure to narrow the focus of your work to a specific marginalized group (or intersection of marginalized identities) and specific issue(s).

On page 6-9, about two different cases in which the

On page 6-9, about two different cases in which the bakers (Jack Philips of Masterpiece Bakery and Marjorie Silva of Azucar Bakery), Corvino argues that one made use-based refusal while the other made design-based refusal. With your own words, explain the differences Corvino makes between two cases; then briefly explain

Christians were persecuted for two centuries because they refused to

   Christians were persecuted for two centuries because they refused to participate in the Imperial Cult of Rome. Eventually, they won over other faiths that were competing with them and persecuting them by holding out hope, being allegiant, equal, and the urge to belong. Christianity required its followers to be

reflect how your experience as a Nursing student has influenced

reflect how your experience as a Nursing student has influenced your interpretation of the Bible. Has your view of the Bible and biblical truth changed since you have been in your Nursing program? How will this experience continue to shape your interpretation as well as an application of the Bible (what

(at least 300 words per prompt) 1. Discuss the five

  (at least 300 words per prompt) 1. Discuss the five types of Hepatitis in terms of etiology, symptoms, treatment and prevention. 2. Discuss is the difference between the etiology and symptoms of cholelithiasis and cholecystitis. Can a person have cholelithiasis and cholecystitis at the same time? How can cholelithiasis

APA FORMAT 1-2 PARAGRAPHS REFERENCES Go to the Newsroom on

 APA FORMAT 1-2 PARAGRAPHS REFERENCES Go to the Newsroom on the U.S. Equal Employment Opportunity Commission’s (EEOC) website and review cases regarding diversity. In the search box under Browse through Press Releases from EEOC, type diversity and review three of the results from your search. List the three cases you

Go to the American Rhetoric website (americanrhetoric.com) and choose a

  Go to the American Rhetoric website (americanrhetoric.com) and choose a speech from the Speech Bank. After checking out the speech, answer the following questions. Questions: What speech did you choose? List the speaker, title, location, and date of the speech. List each type of supporting material—narratives, examples, definitions, testimony,

********See Attached Files for Each Case Study******* Assignment: Answer the

   ********See Attached Files for Each Case Study******* Assignment: Answer the four questions following the case study. Save in SEPARATE Word Documents. Citations should be done using the proper in-text APA format, e.g. (Griffin, 2019, p. xx), An APA format Cover Sheet needs to be submitted and an end of paper Reference

Read Chapters 9–13 in your textbook. Using the discussion link

Read Chapters 9–13 in your textbook. Using the discussion link below, respond to the following prompts and questions: Identify the security components necessary to protect the information systems infrastructure. What key hardware components should be implemented? Why are authentication methods important in assuring that only authorized users are accessing the