• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

help in geting type of words

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

WP
 
lowercase baba
Posts: 12893
63
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
    Bookmark Topic Watch Topic
  • New Topic