2.3 Mark Partition of MN Group
Consecutive digits and punctation characters are grouped together, and then
ungrouped at characters that are marked by ‘x’.
NodeList children = node.getChildNodes();
int n = children.getLength();
char [] digit = new char[n];
for (int i = 0; i < n; i++) {
Node child = children.item(i).getFirstChild();
if( child == null ){
digit[i] = ’x’;
} else if( child.getNodeType() != Node.TEXT_NODE ){
digit[i] = ’x’;
} else {
String s = child.getNodeValue();
if( s.length() != 1 ){
digit[i] = ’x’;
} else {
char ch = s.charAt(0);
if( (ch >= ’0’) && (ch <= ’9’) ){
digit[i] = ’0’; bool = true;
} else if( (ch == ’.’) || (ch == ’,’) ){ digit[i] = ch; }
else { digit[i] = ’x’;}
} } }
-_-_-
bool = false;
for (int i = 0; i < n; i++) {
if( digit[i] == ’.’ ){
for (; i < n; i++) {
if( digit[i] == ’,’ ){
bool = true; break;
} }
break;
} }
-_-_-
if( !bool ){
for (int i = 0; i < n; i++) {
if( digit[i] == ’,’ ){
if( ( ((i+3) >= n)
|| (digit[i+1] != ’0’)
|| (digit[i+2] != ’0’)
|| (digit[i+3] != ’0’)
)
||
(
((i+4) < n) && (digit[i+4] == ’0’)
)
||
(
(i>3) && (digit[i-4] == ’0’)
)
){ bool = true; break;
} else { i += 3; }
} } }
-_-_-
if( bool ){
for (int i = 0; i < n; i++) {
if( digit[i] == ’,’ ){ digit[i] = ’x’; }
} }
-_-_-
bool = false;
for (int i = 0; i < n; i++) {
if( (digit[i] == ’x’)
|| (digit[i] == ’,’) ){ bool = false; }
else if( digit[i] == ’.’ ){
if( bool ){
for (int j = 0; j < n; j++) {
if( (digit[j] == ’.’) || (digit[j] == ’,’) ){
digit[j] = ’x’;
} }
break;
}
bool = true;
} }
-_-_-
if( digit[n-1] == ’.’ ){ digit[n-1] = ’x’; }
-_-_-