In programming C language, write a program that creates a binary
tree of words to be used as a spell
checking device for various text files. The list of words will come
from a file “words.txt”.
Your program is to read through the “words.txt” file and insert the
word on that line into the tree
in lexicographic order (also known as Dictionary order). Words in
the file will be separated by
spaces. Once this is done, your program should then prompt the user
to enter a text file and
then scan through each word in the file to check spelling.
Your program must be able to insert words into and delete words
from the tree. It must also be
able to search the tree for a given string (this is how the spell
check is done), and print the tree
in pre order, in order, and post order.
The functions that do this should look as follows:
● void insert(root, s): node x char* -> none
○ inserts a node whose data is s into the tree with root node
root
● void delete(root, s): node x char* -> none
○ deletes a node whose data is s from the tree with root node
root
● void print_preorder(root): node -> none
○ prints the tree with root node root in pre-order format
● void print_inorder(root): node -> none
○ prints the tree with root node root in in-order format
● void print_postorder(root): node -> none
○ prints the tree with root node root in post-order format
● node search(root, s): node x char* -> node
○ searches a tree with root node root for a node whose data is s,
if it is found then
that node is returned, otherwise a NULL node is returned
For the spell-checking portion of the program, there should be a
function spellcheck which takes
as arguments a root node for your tree, and a string for a
filename. Spellcheck should scan the
file at that location word by word and check if that word is in the
tree, ignoring capitalization and
punctuation (apostrophes are not considered to be punctuation). If
the word is not found then a
message should be printed to the console indicating that word is
not found / misspelled. The
message should indicate the word’s position in the file.
● void spellcheck(root, filename): node x char* -> none
○ Scans a text file (filename) word by word, prints a message to
the console if a
word is not found in the tree of correct words.
Sample Input/Output
words.txt: “all work and no play makes a dull boy”
myInput.txt: “All work and no play maks Jack a dull boy.”
Output:
“Word “maks” on line 1, word 6 mispelled or not found in
dictionary.”
“Word “Jack” on line 1, word 7 mispelled or not found in
dictionary.”
Again, in programming C language please.
In: Computer Science
Please complete in Python and neatly explain and format code. Use snake case style when defining variables. Write a program named wordhistogram.py which takes one file as an argument. The file is an plain text file(make your own) which shall be analyzed by the program. Upon completing the analysis, the program shall output a report detailing the shortest word(s), the longest word(s), the most frequently used word(s), and a histogram of all the words used in the input file.
If there is a tie, then all words that are of the same length for that classification (longest, shortest, most frequent) are displayed as part of that class.
A word histogram shows an approximate representation of the distribution of words used in the input file. An example text, The_Jungle_Upton_Sinclair.txt, is provided as a starting point for analyzing natural language. Draw your histogram by listing the word first and then print up to 65 * characters to represent the frequency of the word.
Since there is limited space on a terminal, ensure that your histogram does not wrap along the right edge of the terminal. Assume that the width of the histogram can not be wider than 65 characters. In calculating your histogram, map the highest frequency to 65 characters. For example, if the text has a word that appears 2000 times and it is the most frequently used word, then divide 2000 by 65 to approximate that each * character represents 30 occurrences of the word in question in the text. Thus if a word should appear less than 30 times, it receives zero * characters, a word that appeared 125 time would receive 4 * characters (0-30, 31-60, 61-90, 91-120, 120-150).
Print the order of the histogram from most frequent to least frequent.
The program must have a class named WordHistogram. This class must be the data structure that keeps track of the words that appear in the input text file and can return the histogram as a single string. The main function is responsible for opening and reading the the input text file.
Make sure your WordHistogram class has data members that are correctly named (use the underscore character!), has an initializer, and any necessary methods and data members.
In your main, use the given function to read from the filehandle.
def word_iterator(file_handle):
""" This iterates through all the words of a given file handle. """
for line in file_handle:
for word in line.split():
yield word
DO NOT COMPUTE OR STORE THE HISTOGRAM OUTSIDE OF AN OBJECT named WordHistogram
Example Output
$ ./wordhistogram.py Candide_Voltaire.txt Word Histogram Report the (2179) ****************************************************************** of (1233) ************************************* to (1130) ********************************** and (1127) ********************************** a (863) ************************** in (623) ****************** i (446) ************* was (434) ************* that (414) ************ he (410) ************ with (395) *********** is (348) ********** his (333) ********** you (317) ********* said (302) ********* not (276) ******** ... $
In: Computer Science
Name the element with atomic number (Z) = 15 and atomic mass number = 31, Use the symbol, not the word.
How many electrons does the neutral atom of this element have? Use a number, not a word.
How many neutrons does the neutral atom of this element have? Use a number, not a word.
In: Chemistry
What are some of the features about Word that you find interesting?
What are some of the features that you find frustrating?
How could Microsoft Word help you in your career?
Are there any other word processing tools that you use in your daily life (e.g. Google Docs)?
In: Computer Science
Language is Java
Design and write a Java console program to estimate the number of syllables in an English word. Assume that the number of syllables is determined by vowels as follows. Each sequence of adjacent vowels (a, e, i, o, u, or y), except for a terminal e, is a syllable. However, the minimum number of syllables in an English word is one.
The program should prompt for a word and respond with the estimated number of syllables in that word. A run of the program should look exactly like this:
Enter a word: hairy
"hairy" has 2 syllables
Cannot use an array!!! Do NOT use continue or break!
My program accepts information fine, I'm just having trouble with the loop that counts how many syllables are in the string.
In: Computer Science
In: Computer Science
python question
<proverbs.txt>
All's well that ends well.
Bad news travels fast.
Well begun is half done.
Birds of a feather flock together.
Please write a program that reads the file you specify and calculates how many times each word stored in the file appears. However, ignore non-alphabetic words and convert uppercase letters to lowercase letters. For example, all's, Alls, alls are considered to be the same words.
What is the output of the Python program when the input file is specified as "proverbs.txt"? That is, in your answer, include the source codes of your word counter program and its output.
Please refer to this
ex)
fname = input("file name: ")
file = open(fname, "r")
table =dict()
for line in file :
words = line. split()
for word= line. split()
if word not in table :
table[word]= 1
else:
table[word] +=1
print(table)
In: Computer Science
public boolean areArrays(int[] arr1, int[] arr2){
// 1. initial check: both arrays need to have the same length,
return false if not the same
// 2. return true if both given arrays are equals(same values in
the same indices), false otherwise
if(arr1.length != arr2.length){
return false;
}
for(int i = 0; i < arr1.length; i++){
if(arr1[i] != arr2[i]){
}
}
return true;
}
public int getIndexOfWord(String[] arr, String word){
// if found, return the index of word, otherwise return -1
for(int i = 0; i < arr.length; i++){
if(arr[i].equals(word)){
return i;
}
}
return -1;
}
public boolean arrayContainsWord(String[] arr, String
word){
// return true if array contains specific word, false
otherwise
for(int i = 0; i < arr.length; i++){
if(arr[i].equals(word));
return true;
}
return false;
}
--- Scanner ------
In: Computer Science
1) Only a single main class is required
2) The main class must contain a static method called "getInputWord" that prompts a user to input a word from the keyboard and returns that word as a String. This method must use "JOptionPane.showInputDialog" to get the input from the user (you can find info about JOptionPane in JavaDocs)
3) The main class must contain a static method called "palindromeCheck" that takes a String as an input argument and returns a boolean indicating whether or not that String is a palindrome. This method must utilize a Stack data structure to determine whether the word is a palindrome. Hint: Use the charAt() method of the String class to access each character of the word
Flow of the Program:
1) Read in a word from the user by calling the "getInputWord" method
2) Check if the word is a palindrome using the "palindromeCheck" method
3) Output the result to the screen using "JOptionPane.showMessageDialog" (you can find info about JOptionPane in JavaDocs)
In: Computer Science
C++ Pig Latin Lab
This assignment uses pointers to perform something done often in computer applications: the parsing of text to find “words” (i.e., strings delineated by some delimiter).
Write a program that encodes English language phrases into Pig Latin. Pig Latin is a form of coded language often used for amusement. Many variations exist in the methods used to form Pig Latin phrases. Use the following algorithm: to form a Pig Latin phrase from an English language phrase, tokenize the phrase into words with the C++ function strtok_s(). To translate each English word into a Pig Latin word, place the first letter of the English word at the end of the English word and add the letters “ay” after it. Thus, the word “jump” becomes “umpjay,” the word “the” becomes “hetay,” and the word “computer” becomes “omputercay.” Blanks between words remain as blanks. Assume that the English phrase input from the keyboard consists of words separated by blanks, there are no punctuations marks, all words have 2 or more letters, and the input phrase is less than 200 characters. Function printLatinWord() should display each word. Hint: Each time a token is found in a call to strtok_s(), pass the token pointer to function printLatinWord() and print the Pig Latin word.
Your program should allow the user to enter phrases until he or she selects an exit option to quit.
In summary: Create a Pig Latin program to implement this functionality: Prompt the user to enter a sentence. Print out the sentence, and then print out the same sentence in Pig Latin. Repeat this sequence until the user elects to quit.
Sol'n so far: (errors in lines 83 and 92)
#include <iostream>
#include <string>
using namespace std;
//class that hold strings of PigLatin
class PigLatin
{
//variable to Piglatin form word
private:
char *latin;
public:
//constructor that converts word into PigLatin
form
PigLatin(char *word)
{
//get the string length
int i, j = 0, len =
strlen(word);
//allocating space
latin = new char[len + 3];
//forming word
for (i = 1; i < len; i++)
{
latin[j] =
word[i];
j++;
}
//Adding last characters
latin[j] = word[0];
j++;
latin[j] = 'a';
j++;
latin[j] = 'y';
j++;
latin[j] = '\0';
}
//Function that returns the word in PigLatin
form
string getLatin()
{
string str(latin);
return str;
}
//Destructor to deallocate memory
~PigLatin()
{
delete[]latin;
}
};
//Function that receives the char * variable as parameter and prints its PigLatin form
void PrintLatinWord(char *str)
{
//creating an object of PigLatin class
PigLatin obj(str);
//Printing word in PigLatin form
cout << obj.getLatin() << " ";
}
//Main function
int main()
{
int i;
char str[200];
char *pch;
char option;
//Loop till user wants to quit
do
{
//Reading a phrase
cout << "\n\n Enter a
sentence to translated:";
cin.getline(str, 200);
//splitting words to
tokens
pch = strtok_s(str, " ");
cout << "\n\t";
//split enter phrase
completes
while (pch != NULL)
{
//Passing
token
PrintLatinWord(pch);
pch =
strtok_s(NULL, " ");
}
//Reading user option
cout << "\n\n Do you want to
enter another sentence? (Y - continue, N - Exit):";
cin.ignore();
} while (option != 'N' && option != 'n');
cout << endl;
system ("pause");
return 0;
}
In: Computer Science