Question
The program must be able to open any text file specified by the user, and analyze the frequency of verbal ticks in the text. Since
The program must be able to open any text file specified by the user, and analyze the frequency of verbal ticks in the text. Since there are many different kinds of verbal ticks (such as "like", "uh", "um", "you know", etc) the program must ask the user what ticks to look for. A user can enter multiple ticks, separated by commas - any spaces entered by the user before or after each tic must be ignored.
The program should output:
- the total number of tics found in the text
- the density of tics (proportion of all words in the text that are tics)
- the frequency of each of the verbal tics
- the percentage that each tic represents out of all the total number of tics
This example shows suggested input/output of such a program. User responses are bold. Data analysis numbers are placeholder only and are not meant to be 'real'.
What file would you like to open? Resemble_Jammed_Inauguration_Speech.txt What words would you like to search for? uh, like, um, you know, so ...............................Analyzing text................................. Total number of tics: 66 Density of tics: 0.2 ...............................Tic breakdown.................................. uh / 19 occurrences / 21% of all tics like / 17 occurrences / 6% of all tics um / 22 occurrences / 21% of all tics you know / 63 occurrences / 32% of all tics so / 18 occurrences / 20% of all tics
- The program must be able to analyze any text file, but an example file must be included in the submission
- The user must be able to enter as many tics as they would like, separated by commas, with or without spaces
- Those tics can either be single words, such as "uh" and "like", or multi-word such as "uh huh" and "you know" - the code must accommodate these as well.
- The list of tics entered by the user must be stored in an array, not an ArrayList or any other array-like data structure
- You must use separate methods for each component of the analysis. At the least, this includes: 1) opening the file and importing its contents, 2) soliciting tic words or phrases from the user and separating them, 3) counting the occurrences of each tic, 4) calculating the percent of all tics that each tic consumes, and 5) calculating tic density.
- The output must be formatted so that all output lines up nicely as in the example
- The search for tics must be case insensitive
- round all occurrences and percentages to the nearest integer
- round the density to two decimal places
Here is what I have so far. But it gives me an error for "tick"
public class TextAnalysis { Run Debug public static void main(String[] args) throws FileNotFoundException { int totwords = 0; int totticks = 0; System.out.print("What file yould you like to open?"); Scanner in = new Scanner(System.in); String input = in.nextLine(); Scanner file = new Scanner (new File(input)); System.out.print("What words would you like to search for?"); String ticks = in.nextLine(); ticks = ticks.toLowerCase(); String[] tick = ticks.split(","); int[] nums = new int [tick. length]; forTicks (nums); public static int[] forTicks (int[] nums) { for (int m=0; mstick.length; m++) { nums [m] = 0; countTicks (nums); public static int[] countTicks (int[] numbers) { //split every line of text and remove extra punctuation characters while (file.hasNext()) { String line = file.next(); totwords = totwords + 1; for (int o=0; ostick.length; 0++) { if (next.toLowerCase().equals(tick[0])) { numbers [0] += 1; for (Integer 1 : numbers) { totticks += 1; ticksDensity(); public static void percentTicks() { public static void percentTicks() { Sysetm.out.println(".........Tick Breakdown............ for (int m=0; mstick.length; m++) { System.out.print(tick[m]); System.out.printf("%105' %n", nums [m], "/", "%-10s' %n", "occurences /",(nums [m]*100/totticks) + "% of all ticks"); public static void ticksDensity() { //instead of void put int if return a number System.out.println("........... Analyzing Text............."); System.out.println("Total number of ticks :" + totticks); //total ticks System.out.printf("Density of ticks: %.2f ", ((totticks/totwords)*100)); percentTicks(); public class TextAnalysis { Run Debug public static void main(String[] args) throws FileNotFoundException { int totwords = 0; int totticks = 0; System.out.print("What file yould you like to open?"); Scanner in = new Scanner(System.in); String input = in.nextLine(); Scanner file = new Scanner (new File(input)); System.out.print("What words would you like to search for?"); String ticks = in.nextLine(); ticks = ticks.toLowerCase(); String[] tick = ticks.split(","); int[] nums = new int [tick. length]; forTicks (nums); public static int[] forTicks (int[] nums) { for (int m=0; mstick.length; m++) { nums [m] = 0; countTicks (nums); public static int[] countTicks (int[] numbers) { //split every line of text and remove extra punctuation characters while (file.hasNext()) { String line = file.next(); totwords = totwords + 1; for (int o=0; ostick.length; 0++) { if (next.toLowerCase().equals(tick[0])) { numbers [0] += 1; for (Integer 1 : numbers) { totticks += 1; ticksDensity(); public static void percentTicks() { public static void percentTicks() { Sysetm.out.println(".........Tick Breakdown............ for (int m=0; mstick.length; m++) { System.out.print(tick[m]); System.out.printf("%105' %n", nums [m], "/", "%-10s' %n", "occurences /",(nums [m]*100/totticks) + "% of all ticks"); public static void ticksDensity() { //instead of void put int if return a number System.out.println("........... Analyzing Text............."); System.out.println("Total number of ticks :" + totticks); //total ticks System.out.printf("Density of ticks: %.2f ", ((totticks/totwords)*100)); percentTicks()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started