Skip to content

Commit

Permalink
fix last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
torifat committed Oct 30, 2011
1 parent 9a24130 commit 1d2de17
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/com/omicronlab/avro/PhoneticParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,20 @@ public String parse(String input) {

String output = "";
for(int cur = 0; cur < fixed.length(); ++cur) {
int start = cur, end = cur + 1, next = end + 1, prev = start - 1;
int start = cur, end = cur + 1, prev = start - 1;
boolean matched = false;
for(Pattern pattern: patterns) {
end = cur + pattern.getFind().length();
if(end <= fixed.length() && fixed.substring(start, end).equals(pattern.getFind())) {
prev = start - 1;
next = end + 1;
for(Rule rule: pattern.getRules()) {
boolean replace = true;

int chk = -1;
int chk = 0;

for(Match match: rule.getMatches()) {
if(match.getType().equals("suffix")) {
chk = next;
chk = end;
}
// Prefix
else {
Expand All @@ -127,8 +126,8 @@ public String parse(String input) {
! (
(chk < 0 && match.getType().equals("prefix")) ||
(chk >= fixed.length() && match.getType().equals("suffix")) ||
this.isPunctuation(fixed.charAt(chk), match.isNegative())
)
this.isPunctuation(fixed.charAt(chk))
) ^ match.isNegative()
) {
replace = false;
break;
Expand All @@ -142,8 +141,8 @@ else if(match.getScope().equals("vowel")) {
(chk >= 0 && match.getType().equals("prefix")) ||
(chk < fixed.length() && match.getType().equals("suffix"))
) &&
this.isVowel(fixed.charAt(chk), match.isNegative())
)
this.isVowel(fixed.charAt(chk))
) ^ match.isNegative()
) {
replace = false;
break;
Expand All @@ -157,8 +156,8 @@ else if(match.getScope().equals("consonant")) {
(chk >= 0 && match.getType().equals("prefix")) ||
(chk < fixed.length() && match.getType().equals("suffix"))
) &&
this.isConsonant(fixed.charAt(chk), match.isNegative())
)
this.isConsonant(fixed.charAt(chk))
) ^ match.isNegative()
) {
replace = false;
break;
Expand All @@ -169,7 +168,7 @@ else if(match.getScope().equals("exact")) {
int s, e;
if(match.getType().equals("suffix")) {
s = end;
e = end + match.getValue().length() - 1;
e = end + match.getValue().length();
}
// Prefix
else {
Expand Down Expand Up @@ -210,16 +209,16 @@ else if(match.getScope().equals("exact")) {
return output;
}

private boolean isVowel(char c, boolean not) {
return ((vowel.indexOf(Character.toLowerCase(c)) >= 0) ^ not);
private boolean isVowel(char c) {
return ((vowel.indexOf(Character.toLowerCase(c)) >= 0));
}

private boolean isConsonant(char c, boolean not) {
return ((consonant.indexOf(Character.toLowerCase(c)) >= 0) ^ not);
private boolean isConsonant(char c) {
return ((consonant.indexOf(Character.toLowerCase(c)) >= 0));
}

private boolean isPunctuation(char c, boolean not) {
return ((punctuation.indexOf(Character.toLowerCase(c)) >= 0) ^ not);
private boolean isPunctuation(char c) {
return ((punctuation.indexOf(Character.toLowerCase(c)) >= 0));
}

private boolean isExact(String needle, String heystack, int start, int end, boolean not) {
Expand Down

0 comments on commit 1d2de17

Please sign in to comment.