Questions
Read the words in from the binary file and figure out how many times each word...

Read the words in from the binary file and figure out how many times each word appears in the file. Display the results to the user.

Use ObjectInputStream to read binary file

Use a HashMap with the word as a key (String) and an Integer as the value. For each word, first check to see if it already exists in the Map. If not, add the word as key with a value of 1 for the Integer value. If it does, get the current value and increment by 1 – replace the old key,value with the new key, value. After all the words are processed and the HashMap is complete. Iterate through the Hash map and display the results in a user -friendly fashion.

Create an easy to read table and print to the console. Hint: Use tabs (/t) (values are not from file)

Example:

Word                     Count

A                             190

Apple                        6

Etc

In: Computer Science

Complete the function, MycountWords in C++, which will count the number of words in a string....

Complete the function, MycountWords in C++, which will count the number of words in a string. We will have different word separators(such as newline(\n), spaces, special symbols(? | \ , . : ;) ) That will separate the words in the giving istringstream. Remember if a words is separated by a hyphen and followed by a new line, they're still one word. The function has an option to be sensitive to case and also avoid duplicates. for duplicates, this is a boolean value that checks whether a word is repeated or not if its set to true and sensitive case is if the word count is sensitive to case and differentiates two words based on their case. even though they have different cases, they are the same word hence duplicates.

complete this function based on the description above.

unsigned int MycountWords(istringstream & iss, bool Duplicate=false, bool SenstiveCase =false) {

}

In: Computer Science

Create the infrastructure for building a word cloud application by (1) Reading the content of a...

Create the infrastructure for building a word cloud application by

(1) Reading the content of a text file and creating a binary tree of words in that file. When a duplicate word is encountered. we simply increase the frequency count of that word in its corresponding node. In other words, the nodes in the tree have two parts. One part maintains the word, and the other maintains the frequency count. It should also be noted that words will not be case sensitive, hence three variations of the word (hello, Hello, HELLO), should be stored in the same node in the tree, and it should have a frequency of 3.

(2) Once the binary tree of words (including their frequency) has been created, we need to print the words and their frequency count (one word per line). (Use InOrder() traversal to display the words and their frequency count)

I have additional files,

  • blacklist.txt (Links to an external site.)
  • testfile.txt (Links to an external site.)
  • datafile.txt

if I have the code I can try link the files

In: Computer Science

In C++ Language English/Spanish Translation Program. Create a menu driven program that translates English to Spanish...

In C++ Language

English/Spanish Translation Program.

Create a menu driven program that translates English to Spanish and Spanish to English.

Your translation program should use arrays for this program. You will need to populate the arrays with the contents of the English and Spanish data files provided. The two files are ordered such that each word in the one file corresponds to the respective translation in the other (i.e.: the first word in the ENG.txt file corresponds to the first word in the SPAN.txt file; the second word in the ENG.txt file corresponds to the second word in the SPAN.txt file, and so on).

Read each file into an array, one array for English words and one for Spanish words. The text files provided each have 100 words. Use a menu driven process.

A message should be displayed if the selected word is not in the dictionary and an error message is displayed if you select an incorrect menu option. Your program must be in a loop so that you can make multiple selections without having to restart your program each time.

In: Computer Science

Code in Java Create a class named DictionaryWord as: DictionaryWord - word: String                            &n

Code in Java

Create a class named DictionaryWord as:

DictionaryWord

- word: String                                                             
- meanings: String

+ DictionaryWord (String word, String meanings)
+ getWord(): String
+ setWord (String word): void
+ getMeanings(): String
+ setMeanings(String meanings): void

Write a program with the following requirements:
Creates 8 DictionaryWord objects with:

  • Word and meanings as the table:

word

meanings

bank robber

Steals money from a bank

burglar

Breaks into a home to steal things

forger

Makes an illegal copy of something

hacker

Breaks into a computer system

hijacker

Takes control of an airplane

kidnapper

Holds someone for ransom money

mugger

Attacks and steals money from someone

murderer

Kills another person

  • Ensure that there is no duplicate DictionaryWord objects (02 DictionaryWord objects a and b are equal when a.word=b.word).

Displays all DictionaryWord with the format as:

<<no>.<<word>>
<<meanings>>

<<no>.<<word>>
<<meanings>>

Where: <<no>>=1,2


Hint:

  • class DictionaryWord implements Comparable to order 2 DictionaryWord objects.
  • override equals(..) method to compare 2 DictionaryWord objects.
  • override toString()
  • use Set to ensure no duplicate.
  • Do not use TreeSet (to show the differences between the Set and TreeSet that Set still remove the duplicate but won't sort the elements)

In: Computer Science

A corpus is a technical term for a collection of texts used to analyze a language...

A corpus is a technical term for a collection of texts used to analyze a language and verify its linguistic properties. The first modern, computer-readable corpus was the Brown Corpus of Standard American English, compiled by Henry Kucera and W. Nelson Francis of Brown University. The Brown Corpus draws from American English texts printed in 1961 and was for many years a widely cited resource in computational linguistics.

The five most frequently occurring words in the Brown Corpus are the, of, and, to, and a. Consider a data set consisting of all occurrences of these words in the Corpus. The values of the variable named Word are and, to, of, the, and a, so Word is a nominal variable with five categories.

Frequency and relative frequency distributions are constructed to summarize the data. They are shown in the table that follows

able 1

Word

Frequency

Relative Frequency

(Thousands of occurrences)

and 28.9 0.1566
to 26.1 0.1415   
of 36.4    0.1973
the 70.0 0.3794
a 23.1 0.1252
Total 184.5 1.0000   

A census is an enumeration of a population. The U.S. Census Bureau conducts a census every 10 years, but in addition, the Population Estimates Program of the bureau publishes population estimates for incorporated places every year. According to 2007 estimates, the five largest U.S. cities (by population) are New York City, Los Angeles, Chicago, Houston, and Phoenix.

Consider a data set consisting of all the residents of these five cities. The values of the variable named City are Phoenix, Chicago, Houston, Los Angeles, and New York City, so City is a nominal variable with five categories. Frequency and relative frequency distributions are provided in the table below.

Table 1

City

Frequency

Relative Frequency

(Millions of people)

Phoenix 1.55 0.0829
Chicago 2.84 0.1519   
Houston 2.21    0.1182
Los Angeles 3.83 0.2048
New York City 8.27 0.4422
Total 18.70 1.0000   

In 1935, Harvard linguist George Zipf pointed out that the frequency of the kth most frequent word in a language is roughly proportional to 1/k. This implies that the second most frequent word in a language has a frequency one-half that of the most frequent word, the third most frequent word has a frequency one-third that of the most frequent word, and so on. A distribution that follows this rule is said to obey Zipf’s Law.

Zipf’s Law has been observed not only in word distributions, but in other phenomena as well, such as the populations of cities. Answer the questions/ blank below in percentages

The frequency of the second most frequent word in the Brown Corpus is ----------- that of the most frequent word. The population of the second largest city in the United States is-------- that of the largest city.

The frequency of the fourth most frequent word in the Brown Corpus is-------------- that of the most frequent word. The population of the fourth largest city in the United States is --------- that of the largest city.

In: Statistics and Probability

in c++ please In this program you are going to have several files to turn in...

in c++ please

In this program you are going to have several files to turn in (NOT JUST ONE!!)

  • hangman.h – this is your header file – I will give you a partially complete header file to start with.
  • hangman.cpp – this is your source file that contains your main function
  • functions.cpp – this is your source file that contains all your other functions
  • wordBank.txt – this is the file with words for the game to use.  You should put 10 words in this text file.

COMPILE THIS WAY:
g++ -Wall -std=c++11 hangman.cpp functions.cpp –o hangman

PROGRAM DESCRIPTION:

You will create a C++ program that will allow the user to play the game Hangman.  Hangman is traditionally a paper & pencil game.  One player thinks of a word and the other player tries to guess it by suggesting letters that may be in the word.  Your program will be player one, by pulling a word from a “word bank” and then player two is the user of your program.  The game is over when one of two things happen:

  • The user correctly completes the word.
  • The user incorrectly guesses a letter six times.

ARRAYS

You will have four arrays.  Three of the arrays will be C-Strings (NOT C++ STRING CLASS STRINGS!!!).  

  • Character array of size 21 (20 characters plus one null-terminator) that will hold the word read in from the “word bank”.  You may assume that the game only plays with words, not phrases.  (No spaces).
    char word[21];
  • Character array of size 21 (20 characters plus one null-terminator) that will at first hold all underscores.  Then, as the user makes correct guesses, the underscores will be replaced with the correct letters.  This means you will have to assign each element to an underscore ‘_’  before the user starts to make any guesses.
    char underScores[21];
  • Character array of size 27 (26 characters plus one null-terminator).  Initialize this array when you define it to all the uppercase letters in the alphabet.  â€œABCDEFGHIJKLMNOPQRSTUVWXYZ”.  
    char alphabet[27] = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
  • Boolean array of size 26 (26 boolean values).  This array will have a true/false toggle for each letter of the alphabet.  If the user has guessed the letter B, then this array at element 1 will have the value of true.  Assign false to each element before the user starts to make any guesses.  
    bool userGuesses[26];

WORD BANK

You will have to create an input file called wordBank.txt.  You need to manually type in TEN or more words to this file.  Your program will not be outputting to this file.  wordBank.txt will be used as an input file only.  Here is one of my wordBank.txt files to see what I mean.  Please do not use my words – make up your own!

FUNCTION:  INT MAIN()

  • Open the input file wordBank.txt.  If the file can’t open, print out a message that a word could not be found in the word bank.
  • Allow the user to play this game (run the program) multiple times.  

SETTING UP FOR THE GAME

  • Set all the elements of the userGuesses array to false
  • Using a loop, set all elements of the underScores array to the underscore character ‘_’.  
  • Set the stage variable to zero (the starting stage)
  • Read in a word from the input file (get the word) – make sure that if the user runs the program multiple times that they get a different word each time from the file.

GAME PLAY

  • While the game has not ended (user is not at stage 6 yet and they have not guessed the word), then do the following:
    • Call the printWord function sending the word array and the underScores array as arguments.
    • Call the printStage function sending the stage variable as an argument.
    • Call the printLettersGuessed function sending the userGuesses array and alphabet array as arguments.
    • Ask the user for their guess.  If it is a lowercase letter, then you need to make it an uppercase letter.  
      cout << “  WHAT LETTER DO YOU GUESS?  â€œ;
      cin >> letter;
      letter = toupper(letter); //the toupper function will make letter uppercase.

      Make sure the letter is not a letter already guessed.  If it is a letter they have already guessed, then force the user to enter in a different letter.  
    • Take the usersGuesses array and make the letter they just guessed true instead of false.  For example, if they guessed the letter ‘C’ then you will need to make usersGuesses[2] = true;
    • Find out if the letter that they guessed is inside the chosen word from the word bank.
      • If the letter guessed is found in the word array, then print out CORRECT! And then put the letter in the underScores array in the same location as the wordFromFile array.
        underScores[x] = word[x];  // where x is an integer incremented by the for loop.
      • If there were no letters found, then print out WRONG!, increment the stage number.  If the stage number is already 6, then call the printStage() function.
      • Tell the user to press enter to continue.
    • Find out if the user has guessed every letter in the word, because if they have, then the game is done and the loop will stop.  
      • Find out the length of the chosen word
        wordLength = strlen(word);
      • Do a special string comparison that will compare two words up to a given length.  The function is strncmp() that you will need to use.  If the chosen word (word array) and theunderScores array match, then the user has guessed the word and the game is over.  Print out a message that the user won the game.

Function:  void printStage(int)

This function will accept as a parameter the current stage and print out the respective diagram to the screen.  Each time the user guesses, a diagram is printed out.  The diagram represents the user being closer and closer to being “hanged” – which is why the game is called Hangman.  At the beginning of the game, the diagram starts at stage 0.  The user will stay at stage 0 (zero) until he or she guesses incorrectly, and then he/she will advance one stage to stage 1.  There are 7 stages (stage 0 to stage 6) to represent the user guessing incorrectly six times.  If the user gets to stage 6, they lose the game.  I have already provided this function for you!

Function:  void printWord(char[], char[])

This function will print out the letters in the word that have already been correctly guessed.  At the beginning of the game, this function should just print out underscores to represent each letter.  This lets the user know how many letters is in the word they are trying to guess.

WORD:  _ _ _ _ _ _ _

Then, as the user guesses a letter, replace the underscore with the letter:

WORD:  W _ _ _ _ _ _

How the function should work:

  • Figure out the length of the character array word (use strlen c-string function)
  • Use a loop to go through as many iterations as the length of word
    • Print out each character of the underScores[] array.  It should be the same length as word.
    • For example, if the word array is ‘R’’A’’V’’E’’N’, then the string length is 5.  Write a for loop that will iterate five times printing out the characters in underScores[] array.  The underScores array may have more than 5 characters in it, but you will only print out 5.

Function:  void printLettersGuessed(bool[], char[])

This function will print out all the letters the user has guessed so far (correct & incorrect).

LETTERS YOU HAVE ALREADY GUESSED:  Q W X Z

How the function should work:

  • Starting at 0, for every element up until 25, if the current element of usersGuesses is true, then output the letter (from the alphabet array) of the same element.  
  • Make sure you print out: “ LETTERS YOU HAVE ALREADY GUESSED:  â€œ before you print out the letters.

In: Computer Science

For this project, you are going to write a program to find the anagrams in a...

For this project, you are going to write a program to find the anagrams in a given dictionary for a given word. If two words have the same letters but in different order, they are called anagrams. For example, “listen” and “silent” are a pair of anagrams.

**JAVA**

First let’s focus on “LetterInventory.java”.

Its purpose is to compute the canonical “sorted letter form” for a given word.

1. Implement the constructor, which takes the String input word. You can assume that the input word contains only valid letters (e.g. no punctuation or blanks), but it may contain letters in different cases.

2. Implement the method: public String getCanonical() It should return the canonical “sorted letter form” for the input word (given in the constructor). It should use only lower cases. For example, if the given word is “AliBaba”, then this method should return “aaabbil”.

****I have already completed all of the above tasks I am struggling with the next part****

**below is the code I have for LetterInventory.java**

import java.util.*;

public class LetterInventory {

   private String input;
  
   //stores the original word.
  
   public LetterInventory(String input) {
       this.input = input;
   }
   //uses an array of chars to hold word and sorts it into alphabetical order.
   //displays it in lower case.
public String getCanonical() {
   input = input.toLowerCase(); // converting input to lower case
   char [] word = input.toCharArray();
   Arrays.sort(word);
   String sorted = new String (word);
   return sorted;
  
}
}

*** this is where i am stuck ***

Once “LetterInventory.java” is working as expected, we can now focus on “AnagramFinder.java”. It will read an input “dictionary” file, which contains quite many words, to build a map. The “key” for the map is a word’s canonical form, the “value” for the map will be all the words in the given dictionary that share the same canonical form. For example, if both “listen” and “silent” are in the dictionary, one entry in the map would have key as “eilnst” and value as an ArrayList of words “listen” and “silent”.

Implement the constructor, which takes in the input dictionary file and build the map. You can assume the words in the dictionary contain only valid letters. You should take advantage of “LetterInventory”.

3. Now implement the method: public void printAnagrams(String word) It should try to search the anagrams for the given word in the map. Again, you can assume the input word contains only valid letters, and you should take advantage of “LetterInventory”.

Print out any anagrams found. For now, don’t worry about the case where the input word is the same as the word inside the dictionary, just print them out.

Here is some sample print out:

Your input is: silent. Found anagrams: listen, silent, tinsel.

Your input is: AliBaba. Sorry, didn’t find any anagrams.

A sample main method is already written for you to test various functionalities with some sample input words.

*** Below is the shell for the main method ***

import java.io.*;
import java.util.*;

public class AnagramFinder {
public static void main(String[] args) throws FileNotFoundException {
String[] originals = new String[] {
"realfun",
"mias",
"EVIL",
"unable",
"Silent",
"AliBaba"
};

for(String original: originals) {
LetterInventory inv = new LetterInventory(original);
System.out.println("Original: " + original + ", Canonical: " + inv.getCanonical());
}

System.out.println("\n");

File f = new File("HW_sample_dict.txt");

AnagramFinder finder = new AnagramFinder(f);

for(String original: originals) {
finder.printAnagrams(original);
}
}

public AnagramFinder(File f) throws FileNotFoundException {
//TODO implement  
}

public void printAnagrams(String word) {
//TODO implement
}

public void printAnagrams2(String word) {
// Extra Credit: optional to implement
}
}

** can leave out extra credit part i just need help with the first 2 methods in the main file **

** the dict.txt is 400 pages long so I did not include it (the file just contains thousands of words) **

In: Computer Science

find 15 words associated with gallbladder and break them down according to the prefix/word root or...

find 15 words associated with gallbladder and break them down according to the prefix/word root or combining form/ suffix and their meaning of the word.

In: Nursing

Write a hangman program in c++.The game is played as follows: 1. The program selects a...

Write a hangman program in c++.The game is played as follows:

1. The program selects a random word for the user to guess (Read words for the user to guess into an array of strings from a file. The words are: revolutionary, meaning, recovery, compartment, trainer, pursuit, harm, platform, error, confusion)

2. User guesses one letter at a time until either they guess the word, or they run out of guesses.

3. Select a random word from the array of strings to the word the user has to guess.

Maintain 2 char arrays:

a. availableLetters: a char array of the available letters the user can choose their guess from. Initialize availableLetters as the lowercase alphabet. As the user guesses letters, replace the corresponding guessed letter with a space to denote the letter has already been guessed.

b. visibleLetters: a char array of the not guessed letters in the word. Initialize visibleLetter to all dashes ("-"). As the user correctly guesses a letter, replace the corresponding dash(es) with the correct letter.

4. The main game loop:

a. Display information regarding the status of the game (visibleLetters, availableLetters, and the number of incorrect guesses remaining (the user gets 7 incorrect guesses)).

b. Prompt the user to enter their guess. If the user tries to guess a letter they have already guessed, inform the user and re-prompt.

c. Exit the loop if the users completely guesses the letters of the word or if the user runs out of incorrect guesses.

Note: relevant string methods you will likely need to use for this program are <string variable>.at(i) to get a character at index position and i and <string variable>.size() (or <string variable>.length() to get the number of characters in the string.

Example output:

The word to guess has 5 letters.

----- 
Available letters: abcdefghijklmnopqrstuvwxyz
7 incorrect guesses remaining.
Please enter your guess: 
s
s is not in the word. Too bad. 6 incorrect guesses remaining.

----- 
Available letters: abcdefghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
e
Nice! e is in the word.

-e---
Available letters: abcd fghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
r
r is not in the word. Too bad. 5 incorrect guesses remaining.

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
r
r is not an available letter

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
l
Nice! l is in the word.

-ell-
Available letters: abcd fghijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
h
Nice! h is in the word.

hell-
Available letters: abcd fg ijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
o
Nice! o is in the word.
Congrats, you guessed the word hello!

In: Computer Science