G
Geoff Warnock
I am writing a Java program (using the jdk 1.5.0) for a project. It
has to read in words from an input file. It is a language translator
so that each line consists of an english word, german, french, spanish
etc. Some of these words contain accents and other characters which
are ascii values of beyond 127.
My problem is that i have a punctuation removal method which strips
all words of unnecessary characters before adding each line to a new
Binary Search Tree Node. The method just drops the ascii values
greater than 127 and does not store them. Why is this happening?
for(int i = 0; i < data.length; i++)
{
int j =0;
while(j != data.length())
{
c = data.charAt(j);
if((c <= 'z') && (c >= 'a'))
temp = temp + c;
else if((c <= 'Z') && (c >= 'A'))
temp = temp + c;
else if(c == 39)
temp = temp + c;
else if((c > (char)127) && (c < (char)168))
temp = temp + c;
else if(c == ' ')
{
if((j > 0) && (j < data.length() - 1))
lastChar = data.charAt(j-1);
nextChar = data.charAt(j+1);
if(((lastChar <= 'z' && lastChar >= 'a') || (lastChar <= 'Z' &&
lastChar >= 'A') || (lastChar == 39)) && ((nextChar <=
'z' && nextChar >= 'a') || (nextChar <= 'Z' && nextChar <= 'A') ||
(nextChar == 39)))
temp = temp + c;
}
}
}
j++;
}
data = temp;
temp = "";
It is the "else if((c > (char)127) && (c < (char)168)) that will not
work. Any ideas??
Thanks, Geoff Warnock.
has to read in words from an input file. It is a language translator
so that each line consists of an english word, german, french, spanish
etc. Some of these words contain accents and other characters which
are ascii values of beyond 127.
My problem is that i have a punctuation removal method which strips
all words of unnecessary characters before adding each line to a new
Binary Search Tree Node. The method just drops the ascii values
greater than 127 and does not store them. Why is this happening?
for(int i = 0; i < data.length; i++)
{
int j =0;
while(j != data.length())
{
c = data.charAt(j);
if((c <= 'z') && (c >= 'a'))
temp = temp + c;
else if((c <= 'Z') && (c >= 'A'))
temp = temp + c;
else if(c == 39)
temp = temp + c;
else if((c > (char)127) && (c < (char)168))
temp = temp + c;
else if(c == ' ')
{
if((j > 0) && (j < data.length() - 1))
lastChar = data.charAt(j-1);
nextChar = data.charAt(j+1);
if(((lastChar <= 'z' && lastChar >= 'a') || (lastChar <= 'Z' &&
lastChar >= 'A') || (lastChar == 39)) && ((nextChar <=
'z' && nextChar >= 'a') || (nextChar <= 'Z' && nextChar <= 'A') ||
(nextChar == 39)))
temp = temp + c;
}
}
}
j++;
}
data = temp;
temp = "";
It is the "else if((c > (char)127) && (c < (char)168)) that will not
work. Any ideas??
Thanks, Geoff Warnock.