Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • 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

Matrix form of files and words

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I want to create a matrix form of files and words in each file i.e., like
files as rows, words as columns.

matrix [ file ][ word ] = (frequency of word in the file)

Is there any logic to do this ?
I tried to create with arrays and hashmaps...
Any help would be highly appreciated.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For parsing text files into words - see the java.io.StreamTokenizer class

In order for the columns to make any sense, it seems to me that you need to start with a dictionary of words to be recognized - all other words to be ignored.

A Hashmap can be used to look up the column number corresponding to a word.

Bill
 
K
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Bill.

I already have the filtered lists of words and their frequencies of each file.
But I'm confused in representing them as a matrix form.

If you can give me a sample code, that will be great.
Do you have any idea about vector space model ?

Thanks a lot.
Krish
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "Matrix form" - what do you mean? Do you have to use some specific matrix math package or are you just looking for a convenient display?
Perhaps this tutorial on arrays of arrays will help.
Bill
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use REXX Associative Arrays are pretty cool.

In Java I'd look into a map keyed by filename holding maps keyed by words. Or the other way around.
 
My pie came with a little toothpic holding up this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic