Search Results

Search found 5 results on 1 pages for 'adam08'.

Page 1/1 | 1 

  • java Getting a list of words from a Trie

    - by adam08
    I'm looking to use the following code to not check whether there is a word matching in the Trie but to return a list all words beginning with the prefix inputted by the user. Can someone point me in the right direction? I can't get it working at all..... public boolean search(String s) { Node current = root; System.out.println("\nSearching for string: "+s); while(current != null) { for(int i=0;i<s.length();i++) { if(current.child[(int)(s.charAt(i)-'a')] == null) { System.out.println("Cannot find string: "+s); return false; } else { current = current.child[(int)(s.charAt(i)-'a')]; System.out.println("Found character: "+ current.content); } } // If we are here, the string exists. // But to ensure unwanted substrings are not found: if (current.marker == true) { System.out.println("Found string: "+s); return true; } else { System.out.println("Cannot find string: "+s +"(only present as a substring)"); return false; } } return false; } }

    Read the article

  • Java Appending a character to a textarea

    - by adam08
    I'm looking to appends a character to a textarea in. I have a simple GUI designed to look like like a mobile phone and I want to be able to click on one of the buttons and update the textarea with that character. If I click another button, I want to be able to append that character to the first. How do I do this? Obviously right now it is just setting the character for that button in the textarea and will be replaced when another button is clicked. public void actionPerformed(ActionEvent e) { String source = e.getActionCommand(); if (source.equals("1")) { TextArea.setText("1"); } else if (source.equals("2abc")) { TextArea.setText("a"); } else if (source.equals("3def")) { TextArea.setText("e"); } else if (source.equals("4ghi")) { TextArea.setText("i"); } else if (source.equals("5jkl")) { TextArea.setText("k"); } else if (source.equals("6mno")) { TextArea.setText("o"); } else if (source.equals("7pqrs")) { TextArea.setText("s"); } else if (source.equals("8tuv")) { TextArea.setText("t"); } else if (source.equals("9wxyz")) { TextArea.setText("x"); }

    Read the article

  • Java action perfmored when text is enterd into a textarea

    - by adam08
    I'm wondering if someone can help me out. I'm entered a chacter into a text area from a button, and want to use the string entered into the textarea to retrieve words from a list. Bear in mind, there could be numerous characters entered. Is it possible for a text area to detect when text has been entered and to action it?

    Read the article

  • Generating the permutations from a number of Characters

    - by adam08
    I'm working on a predictive text solution and have all the words being retrieved from a Trie based on input for a certain string of characters, i.e. "at" will give all words formed with "at" as a prefix. The problem that I have now, is that we are also supposed to return all other possibilities from pressing these 2 buttons, Button 2 and button 8 on the mobile phone, which would also give words formed with, "au, av, bt, bu, bv, ct, cu, cv" (most of which won't have any actual words. Can anyone suggest a solution and how I would go about doing this for calculating the different permutations? (at the moment, I'm prompting the user to enter the prefix (not using a GUI right now)

    Read the article

  • Java: I've created a list of word objects to include the name and the frequency, but having trouble

    - by adam08
    Hi Everyone, I'm working on a project which has a dictionary of words and I'm extracting them and adding them to an ArrayList as word objects. I have a class called Word as below. What I'm wondering is how do I access these word objects to update the frequency? As part of this project, I need to only have one unique word, and increase the frequency of that word by the number of occurrences in the dictionary. Word(String word) { this.word = word; this.freq = 0; } public String getWord() { return word; } public int getFreq() { return freq; } public void setFreq() { freq = freq + 1; } This is how I am adding the word objects to the ArrayList...I think it's ok? String pattern = "[^a-zA-Z\\s]"; String strippedString = line.replaceAll(pattern, ""); line = strippedString.toLowerCase(); StringTokenizer st = new StringTokenizer(line); while (st.hasMoreTokens()) { String newWord = st.nextToken(); word.add(new Word(newWord)); count++; }

    Read the article

1