Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
62
Task/Soundex/Objeck/soundex.objeck
Normal file
62
Task/Soundex/Objeck/soundex.objeck
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
class SoundEx {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
SoundEx("Soundex")->PrintLine();
|
||||
SoundEx("Example")->PrintLine();
|
||||
SoundEx("Sownteks")->PrintLine();
|
||||
SoundEx("Ekzampul")->PrintLine();
|
||||
}
|
||||
|
||||
function : SoundEx(s : String) ~ String {
|
||||
input := s->ToUpper()->Get(0);
|
||||
code := input->ToString();
|
||||
previous := GetCode(input);
|
||||
|
||||
for(i := 1; i < s->Size(); i += 1;) {
|
||||
current := GetCode(s->ToUpper()->Get(i));
|
||||
if(current->Size() > 0 & <>current->Equals(previous)) {
|
||||
code += current;
|
||||
};
|
||||
previous := current;
|
||||
};
|
||||
|
||||
soundex := String->New(code);
|
||||
soundex += "0000";
|
||||
return soundex->SubString(4);
|
||||
}
|
||||
|
||||
function : GetCode(c : Char) ~ String {
|
||||
select(c) {
|
||||
label 'B': label 'F':
|
||||
label 'P': label 'V': {
|
||||
return "1";
|
||||
}
|
||||
|
||||
label 'C': label 'G':
|
||||
label 'J': label 'K':
|
||||
label 'Q': label 'S':
|
||||
label 'X': label 'Z': {
|
||||
return "2";
|
||||
}
|
||||
|
||||
label 'D': label 'T': {
|
||||
return "3";
|
||||
}
|
||||
|
||||
label 'L': {
|
||||
return "4";
|
||||
}
|
||||
|
||||
label 'M': label 'N': {
|
||||
return "5";
|
||||
}
|
||||
|
||||
label 'R': {
|
||||
return "6";
|
||||
}
|
||||
|
||||
other: {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue