Pages: [1]
|
 |
|
Author
|
Topic: Help with Java needed... (Read 4178 times)
|
Der Helm
Terracotta Army
Posts: 4025
|
.... 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.  So ? Anyone interested ? She's cute, btw.  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
|
You probably need to post a picture of her.
|
|
|
|
Der Helm
Terracotta Army
Posts: 4025
|
You probably need to post a picture of her.
I'll ask her. 
|
"I've been done enough around here..."- Signe
|
|
|
craan
Terracotta Army
Posts: 108
... . ...br.. . ..br. . ...br
|
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
|
You probably need to post a picture of her.
I'll ask her.  Got permission... to hotlink, even...  
|
"I've been done enough around here..."- Signe
|
|
|
Der Helm
Terracotta Army
Posts: 4025
|
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
|
|
"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
|
Don't know Java, but I'm willing to learn...  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
|
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
|
|
Palin 2012 : Let's go out with a bang!
|
|
|
Der Helm
Terracotta Army
Posts: 4025
|
Don't know Java, but I'm willing to learn...  No square nails 
|
"I've been done enough around here..."- Signe
|
|
|
Der Helm
Terracotta Army
Posts: 4025
|
OK, got her to translate her task into English... 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 ? 
|
"I've been done enough around here..."- Signe
|
|
|
voodoolily
Contributor
Posts: 5348
Finnuh, munnuh, muhfuh, I enjoy creating new written vernacular, s'all.
|
|
|
|
|
schild
Administrator
Posts: 60350
|
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
|
Any takers ?  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
|
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.  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
|
(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) // 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
|
Lol, that's almost exactly what I had in mind when I asked if we could ignore performance.  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.
|
|
|
|
|
Torinak
Terracotta Army
Posts: 847
|
OK, got her to translate her task into English... 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 ?  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
|
I was thinking something similar to what Evil Evis posted. God bless you Elvis.
|
PWYWWYFSWLSOCA
|
|
|
Tarami
Terracotta Army
Posts: 1980
|
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
|
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  ), 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  ), 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]
|
|
|
 |