Hi I would like to revise the codes below to bring all text files I have text file 0 from 10 I will give you link here
https://drive.google.com/open?id=1LnWqv8ftzARx5Rhf7HtVlVkLVlcA1FtI
when tokenizer read all tokens from the 10 files which attached above, I would like to arrange it in alphabetical order and want to make same word tokens being merged.
For instance,
You are my son?
You are my son and good friend!
you are the only one whom I loved.
The output would be
and
are
friend!
good
I
loved.
my
one
only
son
son?
the
whom
You
you
-> I merged the same words but with the Punctuation, Stemming, and Capitalization, the tokenizers recognize as different word.
Please help me to make this code
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class TokensGeneration {
public static void main(String[] args) throws
FileNotFoundException {
Scanner sc = new
Scanner(System.in);
System.out.print("Enter file name:
");
String file_name =
sc.nextLine();
sc = new Scanner(new
File(file_name));
while(sc.hasNextLine()){
String[] words =
sc.nextLine().split(" ");
for(int i=0;
i<words.length; i++){
System.out.println(words[i]);
}
}
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Test {
public static void main(String[] args) throws
FileNotFoundException {
String sclChar[]={"?","!",".",","};
//list all the signs file may have add more if needed
Set<String> uniqueWord=new
HashSet<String>(); //set will contain unique word
Scanner sc1 = new
Scanner(System.in);
System.out.print("Enter no of
files: ");
int n=sc1.nextInt();
for(int f=0;f<n;f++){
System.out.print("Enter file name: ");
sc1 = new Scanner(System.in);
String file_name = sc1.nextLine();
Scanner sc = new Scanner(new
File("d:\\HomeworkLib\\"+file_name));
while(sc.hasNextLine()){
String line=sc.nextLine(); //read
here line as string
for(int
j=0;j<sclChar.length;j++){ //for each sign
line=line.replace(sclChar[j], ""); //replace it with space
}
String[] words = line.split(" "); //now split the line
into words
for(int i=0; i<words.length; i++){
if(uniqueWord.contains(words[i].toLowerCase())){ //make word lower
case and put to set to avoid issue of low/upper case
continue; //if
set already contain that word skip
}
else{
uniqueWord.add(words[i].toLowerCase()); //else put it into
set
}
}
}
}
ArrayList<String> list = new
ArrayList<>(uniqueWord); //convert set to list
Collections.sort(list); //now sort it
for(String s:list){ //print list one by one
System.out.println(s);
}
}
}
output
Enter no of files: 1
Enter file name: f.txt
and
are
friend
good
i
loved
my
one
only
son
the
whom
you
Hi I would like to revise the codes below to bring all text files I have...
Write a Java method that will take an array of integers of size n and shift right by m places, where n > m. You should read your inputs from a file and write your outputs to another file. Create at least 3 test cases and report their output. I've created a program to read and write to separate files but i don't know how to store the numbers from the input file into an array and then store the...
I've previously completed a Java assignment where I wrote a program that reads a given text file and creates an index that stores the line numbers for where individual words occur. I've been given a new assignment where I need to modify some of my old code. I need to replace the indexer in my Index class with a NavigableMap<String, Word> and update my Word class with NavigableSet<Integer> lines. The instantiated objects should be TreeMap() and TreeSet(). I have below...
I need help with my code when I run my code running the wrong thing like this After downSize() words.length=60003 wordCount=60003 vowelCount=206728 this is my code here import java.io.*; import java.util.*; public class Project02 { static final int INITIAL_CAPACITY = 10; public static void main (String[] args) throws Exception { // ALWAYS TEST FIRST TO VERIFY USER PUT REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) ...
Below I have my 3 files. I am trying to make a dog array that aggerates with the human array. I want the users to be able to name the dogs and display the dog array but it isn't working. //Main File import java.util.*; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.print("There are 5 humans.\n"); array(); } public static String[] array() { //Let the user...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
The Tokenizer.java file should contain: A class called: Tokenizer Tokenizer should have a private variable that is an ArrayList of Token objects. Tokenizer should have a private variable that is an int, and keeps track of the number of keywords encountered when parsing through a files content. In this case there will only be one keyword: public. Tokenizer should have a default constructor that initializes the ArrayList of Token objects Tokenizer should have a public method called: tokenizeFile tokenizeFile should...
hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...
Assignment 3: Word Frequencies Prepare a text file that contains text to analyze. It could be song lyrics to your favorite song. With your code, you’ll read from the text file and capture the data into a data structure. Using a data structure, write the code to count the appearance of each unique word in the lyrics. Print out a word frequency list. Example of the word frequency list: 100: frog 94: dog 43: cog 20: bog Advice: You can...
In this lab you will write a spell check program. The program has two input files: one is the dictionary (a list of valid words) and the other is the document to be spellchecked. The program will read in the words for the dictionary, then will read the document and check whether each word is found in the dictionary. If not, the user will be prompted to leave the word as is or type in a replacement word and add...
2 Date:04/10/2019 3chapter 12.11 Find 4 Program nane: Text I/0 7 package cscl 8- import java. io.File; 9 import java.io.File 10 import java.util.Scanner; 11 public class SalesReportf 12 public static void main(Stringt1 ares) throws Exception (//main method-ai String name,line;//declare string variable-ai 14 16 18 int soldNum;//declare int variable-aj double costPerBottle,retailBottle,profit,percent;//declare multi variable-ai int totalSold-0;//declare and intialic its value-ai double totalCost-e;//declare and intialie its value-ai double totalRetail-0;//declare and intialie its value-ai double totalProfit -0;//declare and intialie its value-ai double totalPercent-8;//declare and...