Ok So I have two strings. The First String is a word, the second string is a sentance. Now the sentence contains the word, and also a definition for the word. See the example below.
Word String : AED Sentence String : This will be much like the “Kindle” or automated external defibrillator (AED).
So I need to find the definition: automated external defibrillator of the word: AED.
What I need to do is parse and find the Definition. I am currently stuck and I need a little help on this. The logic below breaks the word into an array and the sentence into an array. Unfortunately this isn't complete. And also when the logic is looking at the first letter of the word it won't really work as A in AED is uppercase and a in automatic is lowercase.
private void getDefinitions(String word, String sentence) {
if (sentence.contains(word)) {
String[] wordStrAry = word.split("");
String[] sentStr = sentence.split(" ");
for (int sentInt = 0; sentInt < sentStr.length; sentInt++){
for (int wordInt = 0; wordInt < wordStrAry.length; wordInt++) {
wordStrAry[wordInt].trim();
if (!wordStrAry[wordInt].equals("")) {
if (sentStr[sentInt].startsWith(wordStrAry[wordInt])){
System.out.println(sentStr[sentInt]);
}
}
}
}
}
}
One little bit of information I forgot is I need to pull the definition out of the sentence and display it in a text box.
characterto connect yourwordwith its meaning in your sentence, so that you don't have to do so much of comparisons..