This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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: 12792
51
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.
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!