File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes help in geting type of words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help in geting type of words" Watch "help in geting type of words" New topic

help in geting type of words

Hope Smith

Joined: Nov 08, 2012
Posts: 2
hi guys,

I am stuck in some part of my code and I need help please

what I did is split the words and get its positions what I am stuck in is

I want to get the part of speech of each word (noun,verb, adj. ... etc)

how can I do it if I want to read from file (the file has words and its part of speech)

and how can I do it if I intlize multi dim array in my code like this

String [][] dictionaryArr = new String [][] {{"how", "are", "I", "teach"},{"noun", "verb", "noun", "noun"}};

I hope you get my guys

thanks in advanced

William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

How would you format the file?

Think about it. Each word is an Object and has at least two attributes; text and type (nonu,verb etc..)

How would you represent those words in a flat or other (json,xml etc.) structure?

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11313

Hope Smith wrote:
and how can I do it if I intlize multi dim array in my code like this

String [][] dictionaryArr = new String [][] {{"how", "are", "I", "teach"},{"noun", "verb", "noun", "noun"}};

I would say "Don't".

Here's why. When you write software, the absolute WRONG thing to do is say "How do I use <whatever> to do what I need?", and that is what you are doing above. You are saying "How can I use this multi-dimensional array to do what I need?" (and note - technically, you have a one dimensional array that holds arrays).

So...A better approach is to FORGET about Java, data structures, algorithms, etc. Write down instead what you need to do, step by step. pretend you are explaining to a child how to do what you need done. Use actual English words (or any natural language of your choice). So, you might say something like:

Read a bunch of text.
split it apart into individual words
Keep track of each word's position
Identify the part of speech each word is

Then, you go back and look at each line. If you know how to the line, great. If not, go back and revise it into more discrete steps.

Once you have it broken down into the most basic steps, then you start thinking about what would be the best way to hold/store/organize it in your code.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: help in geting type of words