Skip to content

Commit

Permalink
fixed the bug related to "and" as in " one hundred and fifty".
Browse files Browse the repository at this point in the history
  • Loading branch information
aasish committed Apr 29, 2011
1 parent aa12123 commit 99d3a89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Binary file modified bin/PocketSphinxAndroidDemo.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
16 changes: 13 additions & 3 deletions src/edu/cmu/pocketsphinx/demo/SegmentNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static String segmentNum(String wordNumber)

ArrayList<String> items = new ArrayList<String>();
for (int i = 0; i < arrayStr.length; i++){items.add(arrayStr[i]);}

String[] digit = {"one","two","three","four","five","six","seven","eight","nine"};
List list_digit = Arrays.asList(digit);
String[] special = {"zero","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
Expand All @@ -23,6 +22,8 @@ public static String segmentNum(String wordNumber)
List list_ten = Arrays.asList(ten);
String[] hundred = {"one hundred","two hundred","three hundred","four hundred","five hundred","six hundred","seven hundred","eight hundred","nine hundred"};
List list_hundred = Arrays.asList(hundred);
String[] AND = {"and"};
List list_and = Arrays.asList(AND);

ArrayList<String> list = new ArrayList<String>();

Expand All @@ -31,6 +32,7 @@ public static String segmentNum(String wordNumber)
int present_class = 0;
String add_element;
//System.out.println(items.get(i));

if (items.get(i).equals("hundred"))
{
//System.out.println("find hundred");
Expand All @@ -46,15 +48,23 @@ public static String segmentNum(String wordNumber)
}
String final_str = "";
String i = null;
int prev_is_and = 0;
for(int j = 0; j < list.size();j++){
int present_class = 999;
//System.out.println(list.get(j));
i = list.get(j);
if (list_and.contains(i)){prev_is_and = 1;continue;}
if (list_digit.contains(i)){present_class = 1;}
else if(list_ten.contains(i)){present_class = 2;}
else if(list_hundred.contains(i)){present_class = 3;}
else if(list_special.contains(i)){present_class = 0;}
if (present_class != 0){
if (prev_is_and == 1){
final_str = final_str + i +' ';
prev_is_and = 0;


}
else if (present_class != 0){
if(present_class >= prev_class){final_str = final_str +"| "+i+" ";}
else {final_str = final_str + i + " ";}
prev_class = present_class;
Expand All @@ -69,7 +79,7 @@ public static String segmentNum(String wordNumber)
prev_class = present_class;
}
System.out.println(final_str);

return final_str;

}
Expand Down

0 comments on commit 99d3a89

Please sign in to comment.