Number Parsing Exceptions #2

Closed
opened 3 years ago by sigonasr2 · 1 comments
Owner

For numbers specifically, sometimes they can be read as similar letters. They must be accounted for. We can annotate all number variations found:

0: O,o,e
1: \,/,I,i
2: 己
3: 
4:
5:
6: b,G
7: z,Z
8: 
9: g,y
For numbers specifically, sometimes they can be read as similar letters. They must be accounted for. We can annotate all number variations found: ``` 0: O,o,e 1: \,/,I,i 2: 己 3: 4: 5: 6: b,G 7: z,Z 8: 9: g,y ```
sigonasr2 added this to the Arcade Parser milestone 3 years ago
Poster
Owner
char[][] number_alternatives={
        /*0*/{'0','o','O','e'},
        /*1*/{'1','\\','/','I','i'},
        /*2*/{'2'},
        /*3*/{'3'},
        /*4*/{'4'},
        /*5*/{'5'},
        /*6*/{'6','b'},
        /*7*/{'7'},
        /*8*/{'8','B'},
        /*9*/{'9','g','y',},
    };

    int convertToInt(String[]data){return convertToInt(" ",data);}

    int convertToInt(String prefix,String[] data) {
        int numb=0;
        for (int i=0;i<data.length;i++) {
            String s = data[i];
            int j=0;
            if (i==1) {
                j=prefix.length()-1;
            } else {
                j=0;
            }
            for (;j<s.length();j++) {
                letter_iterator:
                for (int k=0;k<number_alternatives.length;k++) {
                    for (int l=0;l<number_alternatives[k].length;l++) {
                        if (s.charAt(j)==number_alternatives[k][l]) {
                            numb*=10;
                            numb+=k;
                            break letter_iterator;
                        }
                    }
                }
            }
        }
        return numb;
    }

Number alternatives are read in and then parses the number appropriately.

```java char[][] number_alternatives={ /*0*/{'0','o','O','e'}, /*1*/{'1','\\','/','I','i'}, /*2*/{'2'}, /*3*/{'3'}, /*4*/{'4'}, /*5*/{'5'}, /*6*/{'6','b'}, /*7*/{'7'}, /*8*/{'8','B'}, /*9*/{'9','g','y',}, }; int convertToInt(String[]data){return convertToInt(" ",data);} int convertToInt(String prefix,String[] data) { int numb=0; for (int i=0;i<data.length;i++) { String s = data[i]; int j=0; if (i==1) { j=prefix.length()-1; } else { j=0; } for (;j<s.length();j++) { letter_iterator: for (int k=0;k<number_alternatives.length;k++) { for (int l=0;l<number_alternatives[k].length;l++) { if (s.charAt(j)==number_alternatives[k][l]) { numb*=10; numb+=k; break letter_iterator; } } } } } return numb; } ``` Number alternatives are read in and then parses the number appropriately.
sigonasr2 closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: sigonasr2/SigPlace#2
Loading…
There is no content yet.