Welcome, Guest. Please login or register.
July 14, 2025, 12:23:35 PM

Login with username, password and session length

Search:     Advanced search
we're back, baby
*
Home Help Search Login Register
f13.net  |  f13.net General Forums  |  General Discussion  |  Topic: Help with Java needed... 0 Members and 1 Guest are viewing this topic.
Pages: [1] Go Down Print
Author Topic: Help with Java needed...  (Read 4178 times)
Der Helm
Terracotta Army
Posts: 4025


on: July 23, 2009, 08:17:14 AM

.... by a fellow student of mine.

Is there someone who would be willing to help her writing a term paper about/with/in the Java language (programming related, Star Wars geeks need not to apply) just raise your hand. She tried to explain the task and her problem to me, but it went right over my head.  swamp poop

So ? Anyone interested ?

She's cute, btw.  DRILLING AND MANLINESS

edit: Just after posting this, it came to my mind that the tech question thread might be the right place to post this, but here it will probably get more eyeballs, move if you think it is necessary.

edit2: Note to self, improve your punctuation skills.
« Last Edit: July 23, 2009, 08:19:16 AM by Der Helm »

"I've been done enough around here..."- Signe
Mosesandstick
Terracotta Army
Posts: 2476


Reply #1 on: July 23, 2009, 09:29:35 AM

You probably need to post a picture of her.
Der Helm
Terracotta Army
Posts: 4025


Reply #2 on: July 23, 2009, 10:25:41 AM

You probably need to post a picture of her.
I'll ask her.  awesome, for real

"I've been done enough around here..."- Signe
craan
Terracotta Army
Posts: 108

... . ...br.. . ..br. . ...br


Reply #3 on: July 23, 2009, 10:57:40 AM

Without any inkling of the task I don't know if you need the super-genius programmer in my office or if I can help with my lesser skills/knowledge.  I'll help if I can.


PWYWWYFSWLSOCA
Der Helm
Terracotta Army
Posts: 4025


Reply #4 on: July 23, 2009, 02:10:04 PM

You probably need to post a picture of her.
I'll ask her.  awesome, for real
Got permission... to hotlink, even...  awesome, for real


"I've been done enough around here..."- Signe
Der Helm
Terracotta Army
Posts: 4025


Reply #5 on: July 23, 2009, 02:11:48 PM

Without any inkling of the task I don't know if you need the super-genius programmer in my office or if I can help with my lesser skills/knowledge.  I'll help if I can.
Something about "reading" "files" from a "directory" "into"  a "programm".

As you might see, I don't know anything about this topic.

"I've been done enough around here..."- Signe
Murgos
Terracotta Army
Posts: 7474


Reply #6 on: July 23, 2009, 02:18:02 PM


"You have all recieved youre last warning. I am in the process of currently tracking all of youre ips and pinging your home adressess. you should not have commencemed a war with me" - Aaron Rayburn
Lantyssa
Terracotta Army
Posts: 20848


Reply #7 on: July 23, 2009, 07:04:10 PM

Don't know Java, but I'm willing to learn... DRILLING AND WOMANLINESS

More seriously, maybe she should type up a quick description of what she needs you can cut-n-paste for us instead of trying to remember terms you don't know about?

Hahahaha!  I'm really good at this!
Kail
Terracotta Army
Posts: 2858


Reply #8 on: July 23, 2009, 11:12:08 PM


I'm just wrapping up my second year of Comp Sci courses (which are mostly done with Java), so I can probably help once that's out of the way, assuming it's fairly basic stuff.
Oban
Terracotta Army
Posts: 4662


Reply #9 on: July 24, 2009, 01:48:52 AM


Palin 2012 : Let's go out with a bang!
Der Helm
Terracotta Army
Posts: 4025


Reply #10 on: July 24, 2009, 01:51:33 AM

Don't know Java, but I'm willing to learn... DRILLING AND WOMANLINESS
No square nails  DRILLING AND MANLINESS

"I've been done enough around here..."- Signe
Der Helm
Terracotta Army
Posts: 4025


Reply #11 on: July 28, 2009, 08:14:58 AM

OK, got her to translate her task into English...

Quote
I have to generate a lexicon for a mobile phone. Several directories with textfiles have to generate the lexicon. The program then has to read the contents of the files, split them into words only and then the single words must be counted so that the most common word will be suggested when a particular combination of keys is pressed.

Any takers ?  awesome, for real


"I've been done enough around here..."- Signe
voodoolily
Contributor
Posts: 5348

Finnuh, munnuh, muhfuh, I enjoy creating new written vernacular, s'all.


WWW
Reply #12 on: July 28, 2009, 10:37:22 AM


Voodoo & Sauce - a blog.
The Legend of Zephyr - a different blog.
schild
Administrator
Posts: 60350


WWW
Reply #13 on: July 28, 2009, 11:34:49 AM

I had to do basically that very same project in my first year of compsci in college. Only not for a mobile phone and not in java because java is the devil's work.

What's her major that she has to do this?
Lantyssa
Terracotta Army
Posts: 20848


Reply #14 on: July 28, 2009, 12:03:53 PM

Any takers ?  awesome, for real
So predictive text, basically.  I have ideas for the concept, but don't know enough java to be of any use on specifics.

Hahahaha!  I'm really good at this!
Samwise
Moderator
Posts: 19324

sentient yeast infection


WWW
Reply #15 on: July 28, 2009, 06:26:07 PM

What precisely is the assignment (you said "term paper" before -- is she supposed to write an essay/paper or actually code the thing?), and what specific part of it does she need help in?  That all sounds pretty straightforward to me, but I don't particularly want to relearn Java and code the whole thing up for her.   awesome, for real

Also, does performance/scalability matter for the purposes of this assignment?  It's pretty easy either way, but if you don't care about performance it's even easier.
« Last Edit: July 28, 2009, 06:29:08 PM by Samwise »
Evil Elvis
Terracotta Army
Posts: 963


Reply #16 on: July 28, 2009, 06:43:01 PM

(This is all drycode, using java 1.5 notation)

This is a very simplistic form of predictive search, so I'll display a simple solution (which wouldn't scale well).  I won't get into the file parsing, as I'm not sure what the file formats are, or what they want these lexicons to look like (if the lexicon actually stores the word frequency, then the wordCount() method is fairly superfluous)




Quote
// A "Dictionary" of our words, storing the occurance count of each word
HashMap<String, Integer> words = HashMap<String, Integer>();

// Everytime you find a word in the text files you parse, pass it into this method
public void countWord(String word)
{
   if (words.containsKey(word))
   {
      Integer occuranceCount = words.get(word) + 1;
      words.put(word, occuranceCount);
   }
   else
   {
      words.put(word, 1);
   }
}

// Returns the best match for currentText
public void predictWord(String currentText)
{
   // Nothing to see here, move along
   if (currentText == null || currentText.isEmpty())
      return "";

   int highestMatchVal = 0;
   String highestMatchWord = "";

   // Loop over every word
   Iterator iter = words.keySet().iterator();
   while ( iter.hasNext() )
   {
      // Find the word that begins with currentText, and has the
      // highest occurance count
      String word = iter.next().toString();
      if ( word.startsWith(currentText) )
      {
         Integer occuranceCount = words.get(word);
         if (count > highestMatchVal)
         {
            highestMatchVal = count;
            highestMatchWord = word;   
         }
      }
   }

   return highestMatchWord;
}



....
Assume a JTextField named "inputField" exists and is displayed
Assume a JLabel named "predictedWordLabel" exists and is displayed
....



inputField.addKeyListener(
   new KeyAdapter()
   {
      public void keyPressed(KeyEvent ke)
      {
         String predictedWord = predictWord( inputField.getText() );
         predictedWordLabel.setText( predictedWord );
      }
   }
);

edit: small fixes
« Last Edit: July 28, 2009, 10:08:31 PM by Evil Elvis »
Samwise
Moderator
Posts: 19324

sentient yeast infection


WWW
Reply #17 on: July 28, 2009, 10:23:34 PM

Lol, that's almost exactly what I had in mind when I asked if we could ignore performance.   why so serious?

For better performance, use a great big hash (hashing not only the words but also all the relevant subsets so that you can do lookups on fragments).  In theory that makes your lookup work in constant time, but that depends on how good the hash implementation is.

Personally, my angle of attack would be to build a tree stucture with each branch corresponding to a letter and each word corresponding to a path in the tree.  As you insert paths into the tree, increment a count on each node that tells you how many paths (words) include it.  That would make your lookup a function of fragment length rather than dictionary size.
Evil Elvis
Terracotta Army
Posts: 963


Reply #18 on: July 28, 2009, 11:05:43 PM

Yeah, a tree is the way to go.

Specifically, a Patricia Tree
Torinak
Terracotta Army
Posts: 847


Reply #19 on: July 28, 2009, 11:15:16 PM

OK, got her to translate her task into English...

Quote
I have to generate a lexicon for a mobile phone. Several directories with textfiles have to generate the lexicon. The program then has to read the contents of the files, split them into words only and then the single words must be counted so that the most common word will be suggested when a particular combination of keys is pressed.

Any takers ?  awesome, for real



Does "particular combination of keys" mean numbers (that may map to multiple letters, such as "1" -> "abc"), or does it mean actual letters?

Is the goal to have any functional program? One that makes use of minimal memory? One with best performance? If the program is for a phone, what JVM(s) and Java versions can one target?

Is the goal to (ab)use standard java.util classes, to write one's own data structures, to discover data structures that may make variants of this problem trivial?

What language are the words in?  How should accent marks be handled?

etc., etc.
craan
Terracotta Army
Posts: 108

... . ...br.. . ..br. . ...br


Reply #20 on: July 29, 2009, 10:01:10 AM

I was thinking something similar to what Evil Evis posted.   God bless you Elvis.

PWYWWYFSWLSOCA
Tarami
Terracotta Army
Posts: 1980


Reply #21 on: July 29, 2009, 03:56:25 PM

As Lantyssa said, this looks like text prediction, not text completion. It takes a slightly different form, but still a radix tree (a dec tree basically, each node having 0-9 as child nodes, which could simply be an array of length 10 for unparallelled memory use/performance.) The paths don't build words, but the keys instead and every node contains a list of words that the qualified key maps to. Each list could be another radix tree, but that's really overshooting the target in my opinion, since every list will be quite succinct (every key can only produce a handful legible words.) The inner list will then be ordered by hits.

If you want to be really fancy-schmancy you could build two radix trees, one for words and one for keys, then cross-reference the trees so that the lists kept in the key tree reference nodes in the word tree and every node in the word tree references the corresponding key node in the other tree, making it one SUPER MEGA TREE! Ahem. Or you could just look-up normally (which would be a little more demanding on memory.)

Either way, that would let you combine completion with prediction, as you can look-up the key in one tree, find the best match there and then go to the word tree for completion suggestions. My phone gives me completion suggestions if I exhaust the prediction list, for example.

- I'm giving you this one for free.
- Nothing's free in the waterworld.
Der Helm
Terracotta Army
Posts: 4025


Reply #22 on: July 29, 2009, 04:06:20 PM

I had to do basically that very same project in my first year of compsci in college. Only not for a mobile phone and not in java because java is the devil's work.

What's her major that she has to do this?
Fennistic, Anglistic and Computer Linguistic.

I THINK she has to come up with some sort of coding herself and THEN she has to write an essay about the linguistic aspects of the code.

Thanks for all that input guys (and gals   DRILLING AND WOMANLINESS), can't answer most of the other questions because I don't know anything about Java or coding.

Anyone who is interested (in helping her out  awesome, for real ), please send me a pm with your email-adresses, I'll get you in touch with the woman herself.

"I've been done enough around here..."- Signe
Pages: [1] Go Up Print 
f13.net  |  f13.net General Forums  |  General Discussion  |  Topic: Help with Java needed...  
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC