I need java code that will go through multiple lines of a text document and find words and punctuation and classify them. I am looking for 4 things Greeting, Place, Name and a Period at the end
---example of text structure:---
Hello world my name is java.
Hello world my name is C++.
Hello my name is Ruby.
-----------------------------------------
the code should produce the following.
word designation
| Word | Designation |
| Hello | Greeting |
| world | place |
| java | name |
| . | period |
ect
the code needs to be dynamic so that I can insert any text document with the structure above. thanks in advance
//CHANGE THE INPUT FILE NAME PATH
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Structure {
public static void main(String[] args) {
File file = new File("input.txt");
try {
//boolean period is for checking
period is there or nota
boolean period=false;
//reading file
Scanner sc = new Scanner(file);
String input=sc.nextLine();
//checking period is there or not
if(input.contains(".")) period=true;
input=input.replace('.', ' ');
//spiliting whole line
String temp[]=input.split(" ");
System.out.println("Word Designaion
------------------------");
//as per the requiement checking weather that has the
names or not
for(int i=0;i<temp.length;i++) {
if(temp[i].trim().equalsIgnoreCase("Hello"))
System.out.println(temp[i]+" Greeting");
else
if(temp[i].trim().equalsIgnoreCase("world"))
System.out.println(temp[i]+" Place");
else
if(temp[i].trim().equalsIgnoreCase("my")) {}
else
if(temp[i].trim().equalsIgnoreCase("name")) {}
else
if(temp[i].trim().equalsIgnoreCase("is")) {}
else System.out.println(temp[i]+"
name");
}
if(period) System.out.println(". Period");
sc.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}



I need java code that will go through multiple lines of a text document and find...
I need help with this problem please, This code needs to be in
Ruby, Java, or Python. See problem below.
-5 - Functional Programming (due Mon] Assignment Content Your software company was invited to provide a proposal for a company in Australia. You currently have the cost in US dollars and need to convert the prices to the Australian dollar. Write a 2-part program using Ruby, Java, or Python. Part 1: Write a function to gather the following costs from...
this us python plz follow the instructions while u solving I
need the code and sane output
QUESTION 1 Write a program that performs the following: 1) request a sentence (at least two words with no punctuation marks) input by the user 2) display the first word 3) display the last letter of the first word 4) display the last word 5) display the first letter of the last word input text can be any content just make sure to...
I need a c++ code that: 1- Read from a text file using C++ example: mytext.txt 2- a function that adds three letters to each latter in that text file for example, if there is a "hello world" inside the text file the function will make it look like "habcezyeloiulghtoiuy wnfroewqrmnilkitduyt" if you note the first latter h follow with three letters abc the e follow with another three zye .... etc so the function is like hashing function that...
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...
Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and cannot figure it out. Thank you. Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and...
******Java Programming Hi guys, I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help! Assignment: Concepts: GUI User Design Graphics Deployment...
I need help with my javascript project, I've started on it but I can't seem to get ym java scripts to work with my index.html. Can someone please help me fix my code? I need the main.js & scratchpad.js to work with my index.html .Thank you Directions: Go to the following link: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics On that page, scroll down to "A 'hello world' example". Follow the step-by-step instructions to download their code and edit it in your text editor of choice....
Hey I need help on Java. I have to create a while loop that reads 5 fields in each row, nextInt, nextInt, next, next, and nextLine. Then I have to instantiate a User object using those 5 fields and insert that object in the usersArr. I just need to see what this would look like if a text file with 5 fields for 5 users existed. Here's my code so far: int [] usersArr = new int[200]; System.out.print("Enter file name:...
I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt Project#3 is an extension of the concepts and tasks of Lab#3. You will again read the dictionary file and resize the array as needed to store the words. Project#3 will require you to update a frequency counter of word lengths every time a word is read from the dictionary into the wordList. When your program is finished this histogram array will contain the following:...
I need help writing this C code. Here is the description: Let's say we have a program called smart typing which does two things: The first letter of a word is always input manually by a keystroke. When a sequence of n letters has been typed: c1c2...cn and the set of words in the dictionary that start with that sequence also have c1c2...cnc then the smart typing displays c automatically. we would like to know, for each word in the dictionary,...