All right, so this isn’t mega-useful, but it would be fun to have a dictionary of words sorted by how they’re spelled on a phone keypad. I don’t even have the slightest idea of a practical use for this, but once in a while I say, “Hey, I didn’t know that ‘blood’ and ‘alone’ are spelled the same!”
5 thoughts on “Predictive Text Encoding Synonym Dictionary”
Comments are closed.
There’s certainly a shorter way but…
#!/usr/bin/perl
# pass it something like /usr/share/dict/words
use strict;
my (%values, %words, $value, $word);
@values{ 'a'..'z' } = (2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9);
while () {
if (/^(w+)$/) {
$word = lc $1;
$value = join "", map { $values{$_} } split //, $word;
push @{$words{$value}}, $word;
}
}
foreach $value (sort {$a $b} keys %words) {
print "$valuen";
foreach $word (sort @{$words{$value}}) {
print "t$wordn";
}
}
LikeLike
I forgot about duplicate words.
#!/usr/bin/perl
# pass it something like /usr/share/dict/words
use strict;
my (%values, %words, $value, $word);
@values{ 'a'..'z' } = (2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9);
while (<>) {
if (/^(w+)$/) {
$word = lc $1;
$value = join "", map { $values{$_} } split //, $word;
$words{$value}{$word} = 1;
}
}
# another sort order might make more sense
foreach $value (sort {$a <=> $b} keys %words) {
print "$valuen";
foreach $word (sort keys %{$words{$value}}) {
print "t$wordn";
}
}
LikeLike
I’m trying to find out what these word pairs / families are called – people have suggested ‘text twins’. I quite like the sound of ‘predictinyms’. Does a word exist? If not we should thing of a good one!
Dunstan
LikeLike
ps leave a message on my blog http://www.ozdunstan.blogspot.com if you have any ideas…
LikeLike
Words (or pseudo-words!) which are the same in T9 are synokia. Presumably from Greek ‘syn’, with, and ‘Nokia’, the god of mobile phones.
LikeLike