Codebase list letterize / 90e95a7
Imported Upstream version 1.3 Francois Marier 13 years ago
7 changed file(s) with 504 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 BSD LICENSE
1
2 Redistribution and use in source and binary forms, with or without
3 modification, are permitted provided that the following conditions
4 are met:
5
6 Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8
9 Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12
13 Neither name of the this project nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 #
1 # Makefille for the phone-number letterizer
2 #
3 VERS=$(shell sed <letterize.spec -n -e '/Version: \(.*\)/s//\1/p')
4
5 all: letterize
6
7 letterize: letterize.c
8
9 SOURCES = README COPYING letterize.xml Makefile letterize.c letterize.spec
10
11 letterize.1: letterize.xml
12 xmlto man letterize.xml
13
14 letterize.html: letterize.xml
15 xmlto html-nochunks letterize.xml
16
17 letterize-$(VERS).tar.gz: $(SOURCES) letterize.1
18 @ls $(SOURCES) letterize.1 | sed s:^:letterize-$(VERS)/: >MANIFEST
19 @(cd ..; ln -s letterize letterize-$(VERS))
20 (cd ..; tar -czf letterize/letterize-$(VERS).tar.gz `cat letterize/MANIFEST`)
21 @(cd ..; rm letterize-$(VERS))
22
23 clean:
24 rm -f letterize letterize.tar letterize*.gz letterize*.rpm
25 rm -f *~ *.1 *.html MANIFEST SHIPPER.*
26
27 install: uninstall letterize.1
28 cp letterize /usr/bin
29 cp letterize.1 /usr/share/man/man1/letterize.1
30
31 uninstall:
32 rm -f /usr/bin/letterize /usr/share/man/man1/letterize.1
33
34 dist: letterize-$(VERS).tar.gz
35
36 release: letterize-$(VERS).tar.gz letterize.html
37 shipper -u -m -t; make clean
0 letterize -- phone digits to letter-mnemonics
1 by Eric S. Raymond <esr@snark.thyrsus.com> Oct 24 1994
2
3 I built this around some code for detecting pronounceable letter combinations
4 that I picked up off the net. Not sure who wrote it.
5
6 Files:
7
8 README -- this file
9 letterize.c -- the code
10 Makefile -- A simple Makefile
11 letterize.1 -- man page
12 letterize.xml -- XML DocBook master for the man page
13
14 Bugs. Don't talk to me about bugs. Email me at esr@thyrsus.com instead.
15
16 You can surf to http://www.catb.org/~esr/ for updates and related resources.
17
0 '\" t
1 .\" Title: letterize
2 .\" Author: [see the "AUTHOR" section]
3 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
4 .\" Date: 10/20/2010
5 .\" Manual: Miscellanea
6 .\" Source: letterize
7 .\" Language: English
8 .\"
9 .TH "LETTERIZE" "1" "10/20/2010" "letterize" "Miscellanea"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 letterize_ \- phone\-number to letter\-mnemonic generator
31 .SH "SYNOPSIS"
32 .HP \w'\fBletterize\fR\ 'u
33 \fBletterize\fR \fInnnnnnn\fR
34 .SH "DESCRIPTION"
35 .PP
36 This program tries to help you find a letter mnemonic matching a given phone number\&.
37 .PP
38 It emits to standard output each possible pronounceable mnemonic, one per line, using the American standard mapping of dial letters to numbers (2 goes to ABC, 3 to DEF, 4 to GHI, 5 to JKL, 6 to MNO, 7 to PRS, 8 to TUV, 9 to XYZ)\&.
39 .PP
40 The program uses a table of pronounceable letter\-triples derived from a dictionary scan\&. Each potential mnemonic must be such that all of its letter\-triples are in the table to be emitted\&. About 30% of possible triples are considered pronounceable\&.
41 .PP
42 A typical 7\-digit phone number has 19,683 possible mnemonics, but this test usually cuts the list down to a few hundred or so, a reasonable number to eyeball\-check\&. For some numbers, the list will, sadly, be empty\&.
43 .PP
44 It\*(Aqs best to leave out punctuation such as dashes and parens\&.
45 .SH "BUGS"
46 .PP
47 The filtering method doesn\*(Aqt know what plausible medial triples are not reasonable at the beginnings and ends of words\&.
48 .PP
49 I\*(Aqm not sure what table position 0 (which is what 0 and 1 are mapped to) means\&. If you figure it out, you tell me\&. I really should have generated my own table, but that would have been more work than this seemed worth \-\- if your number contains either, you probably need to generate your mnemonic in disjoint pieces around the digits anyway\&.
50 .SH "AUTHOR"
51 .PP
52 Eric S\&. Raymond
53 esr@snark\&.thyrsus\&.com\&. It\*(Aqs based on a table of plausible letter\-triples that had no name attached to it\&. Surf to
54 \m[blue]\fBhttp://www\&.catb\&.org/~esr/\fR\m[]
55 for updates and related resources\&.
0 /*
1 * letterize.c -- generate all mnemonics corresponding to a phone number
2 *
3 * by Eric S. Raymond <esr@snark.thyrsus.com>, Oct 24 1994
4 *
5 * Everything between the CUT HEREs was copied from a code fragment I found
6 * on the net, unattributed.
7 *
8 * ------------------------------ CUT HERE -----------------------------------
9 */
10 /*
11 Table of triple usage in text
12
13 24511 words were used to make this table.
14 The words came from the files:
15 /usr/dict/words
16 obvpats.lp
17
18 The table is 30 percent populated.
19 */
20 long obvtab[27][27] =
21 {
22 { 0X00100001, 0X00040000, 0X00040000, 0X00009000, 0X00808020, 0X00140000,
23 0X00000000, 0X00080000, 0X00000002, 0X00000000, 0X00000000, 0X00000000,
24 0X00001020, 0X00000000, 0X00000010, 0X00000020, 0X00000000, 0X00000000,
25 0X00000030, 0X00300100, 0X00000100, 0X00000000, 0X00000020, 0X00000000,
26 0X00000000, 0X00000000, 0X00000000 },
27 { 0X00090000, 0X000c708a, 0X022cd73e, 0X023ffbbe, 0X02fffffe, 0X002cd0da,
28 0X023cdae2, 0X02adf3b6, 0X0024f222, 0X00dd7efa, 0X00008022, 0X02b5937a,
29 0X06fdfbfe, 0X02bdf37e, 0X07ffdfff, 0X003c3248, 0X023dfb76, 0X00200000,
30 0X07fffffe, 0X02bbfbbe, 0X06bcfb6f, 0X055f7dfc, 0X02609232, 0X021cfbf6,
31 0X02999222, 0X00bdf3ff, 0X06308232 },
32 { 0X00080000, 0X07fdfbfc, 0X022c9226, 0X00008012, 0X00248222, 0X07dffbfe,
33 0X00200000, 0X00000000, 0X00208020, 0X047ffdfe, 0X00000020, 0X00000000,
34 0X02208222, 0X00800220, 0X0000a022, 0X03fdfffe, 0X00048000, 0X00000000,
35 0X02208222, 0X00308228, 0X00049062, 0X071efefc, 0X00000220, 0X00000020,
36 0X00000000, 0X049d11a2, 0X00000000 },
37 { 0X00080080, 0X02fffffe, 0X000c0020, 0X0024932a, 0X0000802a, 0X06bdf3fe,
38 0X00000002, 0X00248220, 0X02bdf3fe, 0X007df0fe, 0X00000000, 0X02bdfffe,
39 0X02208222, 0X00200222, 0X00008222, 0X07fffffe, 0X00000102, 0X00200000,
40 0X02308222, 0X00188200, 0X02aca262, 0X003df27e, 0X00000004, 0X00000000,
41 0X00000000, 0X001dd08e, 0X00000022 },
42 { 0X00088022, 0X06fd7bfc, 0X02249222, 0X00209102, 0X02249332, 0X07fff7fe,
43 0X00249282, 0X02a43a22, 0X00008222, 0X05fdf3fe, 0X00208022, 0X00000220,
44 0X02208222, 0X00208222, 0X00008223, 0X07fdf3fe, 0X00049322, 0X00200000,
45 0X02208222, 0X0091bb2a, 0X00008302, 0X043dfafe, 0X00008222, 0X02048222,
46 0X00000000, 0X00987aef, 0X00200000 },
47 { 0X004c1030, 0X04ff79dc, 0X023c9226, 0X023c9b3a, 0X02bdf3fe, 0X04ddfbfe,
48 0X023c92fa, 0X0224f3e6, 0X0224a222, 0X045d7afa, 0X00208022, 0X0218ca36,
49 0X02fdfbfe, 0X02a9f22e, 0X06ffffff, 0X05fd73d8, 0X02bdb32e, 0X00200000,
50 0X07fffffe, 0X02fbfbbe, 0X06bdfb6e, 0X005d78bc, 0X066c8222, 0X029df37e,
51 0X0333832a, 0X008df97f, 0X06648222 },
52 { 0X00080000, 0X07bc7bfe, 0X00000222, 0X0000000a, 0X00008002, 0X02fc7abe,
53 0X022cb366, 0X00000102, 0X00000022, 0X055c70fe, 0X00008000, 0X00000002,
54 0X02208222, 0X0000000a, 0X00000200, 0X03edf2be, 0X00000008, 0X00000000,
55 0X02208222, 0X00118922, 0X028ca32e, 0X041c74b8, 0X00000000, 0X00000002,
56 0X00000000, 0X00000000, 0X00000000 },
57 { 0X00080000, 0X06fdf3fc, 0X00008222, 0X00000000, 0X00008022, 0X02fdf3fe,
58 0X00240220, 0X020d93a2, 0X02bddffe, 0X047df0fe, 0X00000002, 0X00008200,
59 0X02208222, 0X02300222, 0X00318226, 0X02fdf3fe, 0X00009220, 0X00000000,
60 0X02208222, 0X00919b06, 0X00048302, 0X061cf2ee, 0X00000000, 0X02048022,
61 0X00000000, 0X00056002, 0X00000002 },
62 { 0X00080000, 0X06fdfbfe, 0X02249222, 0X00048102, 0X00048202, 0X07fff2ff,
63 0X00208202, 0X00008022, 0X00008122, 0X047dfcfe, 0X00000800, 0X00008220,
64 0X02248222, 0X0008a222, 0X0028c222, 0X06fdfeff, 0X00209202, 0X00200000,
65 0X02249232, 0X00108302, 0X02bdf3fa, 0X071d71fe, 0X00000200, 0X00008322,
66 0X00000000, 0X011d32be, 0X00000000 },
67 { 0X00483010, 0X05dd7bbc, 0X022cf226, 0X023cdb2a, 0X02bdf6b6, 0X04fd79fc,
68 0X0234d262, 0X063df3a2, 0X00000222, 0X00000202, 0X00208002, 0X02208a22,
69 0X02fdbbfe, 0X022df36e, 0X07ffffff, 0X05fd70be, 0X02bdb766, 0X00200000,
70 0X02fdfafe, 0X02ffffff, 0X06bdfb6f, 0X000c7008, 0X02248222, 0X00008202,
71 0X023082e2, 0X00000002, 0X04608022 },
72 { 0X00080000, 0X07ed7bbc, 0X00000000, 0X00000000, 0X00000000, 0X009cd57a,
73 0X00000000, 0X00000000, 0X00000000, 0X005070c4, 0X00000400, 0X00001000,
74 0X00000000, 0X00000000, 0X00000000, 0X02fc5bae, 0X00000000, 0X00000000,
75 0X00000000, 0X00000000, 0X00000000, 0X015d7e96, 0X00000000, 0X00000000,
76 0X00000000, 0X00000000, 0X00000000 },
77 { 0X00080000, 0X07fdfff4, 0X00248222, 0X00040302, 0X00048022, 0X02fdf3f6,
78 0X00208222, 0X00048000, 0X0014a022, 0X00ddf8fe, 0X00000002, 0X0000ca22,
79 0X0220a222, 0X00000022, 0X00208222, 0X01fdfb7a, 0X00009202, 0X00000000,
80 0X02208222, 0X02b1abae, 0X00048302, 0X029d7110, 0X00000000, 0X00008322,
81 0X00000000, 0X00ac9522, 0X00000000 },
82 { 0X00088000, 0X07fffbfe, 0X02249222, 0X0234b322, 0X02bdf36e, 0X07fdfffe,
83 0X00bc93e6, 0X00048222, 0X00008222, 0X05fffdfe, 0X00008000, 0X0288d322,
84 0X02bdb7fe, 0X0228e332, 0X00208020, 0X07fffffe, 0X021ca362, 0X00000000,
85 0X02208022, 0X0299ab26, 0X06eca326, 0X055dfefe, 0X00008222, 0X02008322,
86 0X00000000, 0X00bdfbfe, 0X00000022 },
87 { 0X00080000, 0X07fdffbc, 0X002dd236, 0X0021fbfe, 0X00008020, 0X07ddfbfe,
88 0X00209220, 0X00000000, 0X00208020, 0X053efcfa, 0X00000000, 0X00000000,
89 0X00008222, 0X0220a222, 0X02208222, 0X07fdfbfe, 0X023c9be6, 0X00200000,
90 0X00088002, 0X0239a37c, 0X00048120, 0X041dfaf8, 0X00000020, 0X00008222,
91 0X00000000, 0X001cd0a8, 0X00000000 },
92 { 0X00180000, 0X06fdfbfe, 0X002c922a, 0X02349b22, 0X02bffffe, 0X07fff3ff,
93 0X00249222, 0X02bdbb76, 0X02208222, 0X057ffbfe, 0X00208022, 0X021d33ea,
94 0X02008222, 0X00008222, 0X0228c222, 0X07fdf2fe, 0X00209220, 0X00200000,
95 0X0220822a, 0X02fdfbfe, 0X06adf3ee, 0X043dfafe, 0X02208222, 0X00048322,
96 0X00100200, 0X01ffb11e, 0X02808222 },
97 { 0X0008113c, 0X017f79da, 0X02fcd77e, 0X02349b2a, 0X02adfbfe, 0X037ef35c,
98 0X0234b262, 0X02bcf7f6, 0X0204f222, 0X011c58fe, 0X00008222, 0X02a99b2e,
99 0X06fdfbfe, 0X02aff36e, 0X07ffffff, 0X045df9dc, 0X02bffbae, 0X00200000,
100 0X06fffbfe, 0X02fbbbae, 0X02bdf3ee, 0X055f73ff, 0X02008a22, 0X06bdfb7e,
101 0X02d043ea, 0X001dd37e, 0X06008222 },
102 { 0X00080000, 0X07fffabc, 0X002c9022, 0X00008100, 0X00040002, 0X07fdfefe,
103 0X00241220, 0X00040002, 0X023cd232, 0X057ff8fa, 0X00000002, 0X00000220,
104 0X02208222, 0X00208022, 0X00008020, 0X03fdfafa, 0X022db322, 0X00040000,
105 0X02208222, 0X02b0bb2a, 0X0224832a, 0X041d7afe, 0X00000008, 0X00048202,
106 0X00000000, 0X00949b86, 0X00000000 },
107 { 0X00080000, 0X00100000, 0X00000000, 0X00000000, 0X00000000, 0X00000010,
108 0X00000000, 0X00000000, 0X00000000, 0X00000000, 0X00000000, 0X00000000,
109 0X00000000, 0X00000000, 0X00000000, 0X00000000, 0X00000000, 0X00020000,
110 0X00080000, 0X00000000, 0X00000000, 0X02008222, 0X00000000, 0X00000020,
111 0X00000000, 0X00000000, 0X00000000 },
112 { 0X00080010, 0X07fffffc, 0X022c9222, 0X023c9b2a, 0X02bdd366, 0X07ffffff,
113 0X00249222, 0X022cb322, 0X02208222, 0X07fbfdfe, 0X00208020, 0X029df336,
114 0X02b98236, 0X0239936e, 0X02b9ab66, 0X07fffffe, 0X023cb322, 0X00200000,
115 0X02248322, 0X02f3fb7e, 0X06bcf3ee, 0X01ddf2fe, 0X02208222, 0X00008222,
116 0X00000020, 0X0099f0be, 0X00008222 },
117 { 0X00081000, 0X03fdfffe, 0X02248222, 0X0224b323, 0X00248242, 0X07fffbfe,
118 0X02208222, 0X002c8220, 0X02f5fa6e, 0X057ff8fe, 0X00200000, 0X0224a222,
119 0X02208222, 0X02208222, 0X02208223, 0X06f5f7fe, 0X022c9326, 0X00200000,
120 0X00288222, 0X02bdf36e, 0X02edf7ff, 0X041df2fe, 0X00010220, 0X00248222,
121 0X00000000, 0X001d78bc, 0X00000000 },
122 { 0X001c1010, 0X03fdfbfc, 0X00248222, 0X02249102, 0X00048000, 0X03fdfbfe,
123 0X00249222, 0X00248022, 0X02bffbfe, 0X047ff8fe, 0X00000000, 0X02000222,
124 0X02208222, 0X00208222, 0X00308223, 0X07fdfafe, 0X00049222, 0X00000000,
125 0X02a08222, 0X02f1ab7e, 0X027c9be2, 0X031df2fe, 0X00000202, 0X01208322,
126 0X00000000, 0X01ad328e, 0X000db2a2 },
127 { 0X004c1010, 0X02dd7bdc, 0X027db736, 0X023c9b2a, 0X06ac92b6, 0X063df5f6,
128 0X0030b042, 0X002cf3a2, 0X00004002, 0X057dd0be, 0X00208202, 0X00048a30,
129 0X06fdfafe, 0X007bf36e, 0X02bdfbfe, 0X023d5210, 0X02bdbbfe, 0X00200000,
130 0X06fffbfe, 0X023bdbbe, 0X06bcf3be, 0X00202000, 0X00840220, 0X00000002,
131 0X00309220, 0X00601022, 0X04208022 },
132 { 0X00080000, 0X003d7fbc, 0X00004000, 0X00000000, 0X00000002, 0X039dfbfe,
133 0X00000000, 0X00000000, 0X00000000, 0X057cdafe, 0X00000000, 0X00000100,
134 0X00008002, 0X00000000, 0X00000000, 0X02bcfa88, 0X00000000, 0X00000000,
135 0X00008020, 0X00000800, 0X00000000, 0X000c1000, 0X02400220, 0X01000000,
136 0X00000000, 0X00800200, 0X00008000 },
137 { 0X00080000, 0X077d7bde, 0X00248222, 0X00208102, 0X02248220, 0X025d53bf,
138 0X00209202, 0X00000200, 0X02208222, 0X055d70f8, 0X00000000, 0X02804200,
139 0X02180222, 0X00000222, 0X02bd03fc, 0X00fdf864, 0X00209222, 0X00000000,
140 0X02008222, 0X02bdbb2c, 0X00208322, 0X00057100, 0X00000000, 0X00808002,
141 0X02000000, 0X0000f022, 0X02000000 },
142 { 0X00080000, 0X005870d8, 0X00000000, 0X00649322, 0X00000000, 0X021c7298,
143 0X00008000, 0X00201000, 0X00208202, 0X0058f0fe, 0X00000000, 0X00000000,
144 0X00000020, 0X00000000, 0X00000002, 0X001d6090, 0X00249222, 0X00200000,
145 0X00000000, 0X00000020, 0X02248326, 0X00051016, 0X00000200, 0X00008020,
146 0X01008000, 0X04041080, 0X00000000 },
147 { 0X004c1010, 0X0097f998, 0X00248232, 0X00009322, 0X0004c226, 0X00ddf0f6,
148 0X00201222, 0X0224f230, 0X02048020, 0X00094030, 0X00000002, 0X00004420,
149 0X00699a22, 0X0221e22e, 0X0310c3ba, 0X04fd78d8, 0X023dd322, 0X00200000,
150 0X0234c272, 0X0039b32e, 0X02108322, 0X00095b88, 0X00000022, 0X0004832a,
151 0X00000200, 0X02000000, 0X00000002 },
152 { 0X00080000, 0X00557b8e, 0X00000000, 0X00000000, 0X00000002, 0X00bc5a3e,
153 0X00000000, 0X00000020, 0X00000000, 0X003df0ae, 0X00000000, 0X00000000,
154 0X02008020, 0X00000002, 0X00000000, 0X0065e2b2, 0X00000002, 0X00000000,
155 0X00008002, 0X00000008, 0X00000020, 0X00040820, 0X00008020, 0X00008020,
156 0X00000008, 0X00002084, 0X06809222 } };
157 /*
158 Configuration parameters
159 */
160 short unusual; /* count of unusual triples */
161
162 /*
163 dotriple -- called by obvword
164
165 If this triple is not used by any word used to build the table,
166 we tally that fact.
167 */
168 dotriple(m1,m2,m3)
169 short m1,m2,m3; /* all in 0..26 */
170 {
171 if (!(obvtab[m1][m2] & (1L << m3))) unusual++; /* check for triple */
172 }
173
174 /*
175 * ------------------------------ CUT HERE -----------------------------------
176 */
177
178 #include <stdio.h>
179
180 /*
181 obvword -- do one word
182
183 dotriple is called on each 3-character triple in the word,
184 using a mapped value of the character into the range 0..26,
185 where letters map into 1..26 regardless of case and everything
186 else maps to zero.
187 */
188 obvword(word)
189 char word[]; /* word to do, max 20 chars */
190 {
191 register int i; /* for loops */
192 register int patcnt = 0; /* count in word */
193 register char ch; /* working char */
194 short pat[21]; /* pattern of mapped values */
195
196 unusual = 0;
197 for (i=0; word[i] && (i < sizeof(pat)); i++) /* scan until null */
198 {
199 patcnt = i; /* max value */
200 ch = word[i]; /* get character */
201 if ((ch >= 'a') && (ch <= 'z')) pat[i] = ch + 1 - 'a';
202 else if ((ch >= 'A') && (ch <= 'Z')) pat[i] = ch + 1 - 'A';
203 else pat[i] = 0; /* map into 0..26 */
204 }
205 for (i=0; i < patcnt - 1; i++) /* for all triples */
206 dotriple(pat[i], pat[i+1], pat[i+2]); /* do the triple */
207 return(unusual == 0);
208 }
209
210 void phone_gen(s, i)
211 /* print out all trailing substrings of s that satify obvword() */
212 char *s;
213 int i;
214 {
215 static char *digitrans[]
216 = { "abc", "def", "ghi", "jkl", "mno", "prs", "tuv", "wxy" };
217
218 char c, *s2;
219
220 c = s[i];
221
222 if (c == '\0')
223 {
224 if (obvword(s))
225 (void) printf("%s\n", s);
226 }
227 else if ('2' <= c && c <= '9')
228 for (s2 = digitrans[c-'2']; s[i]= *s2++;)
229 phone_gen(s, i+1);
230 else
231 phone_gen(s, i+1);
232
233 s[i] = c;
234 }
235
236 main(argc, argv)
237 int argc;
238 char **argv;
239 {
240 for (; --argc > 0; printf("\n"))
241 phone_gen(*++argv, 0);
242
243 return(0);
244 }
245
246 /* letterize.c ends here */
0 Name: letterize
1 Version: 1.3
2 Release: 1
3 Summary: generate pronounceable mnemonics from phone numbers
4 URL: http://www.catb.org/~esr/letterize/
5 Source0: %{name}-%{version}.tar.gz
6 License: BSD
7 Group: Applications
8 BuildRoot: %{_tmppath}/%{name}-root
9
10 %description
11 Generate all possible alphabetic mnemonics for a phone
12 number, then filter them for phonetic plausibility in
13 English.
14
15 %prep
16 %setup -q
17
18 %build
19 make %{?_smp_mflags} letterize letterize.1
20
21 %install
22 [ "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"
23 mkdir -p "$RPM_BUILD_ROOT"%{_bindir}
24 mkdir -p "$RPM_BUILD_ROOT"%{_mandir}/man1/
25 cp letterize "$RPM_BUILD_ROOT"%{_bindir}
26 cp letterize.1 "$RPM_BUILD_ROOT"%{_mandir}/man1/
27
28 %clean
29 [ "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"
30
31 %files
32 %defattr(-,root,root,-)
33 %{_mandir}/man1/letterize.1*
34 %{_bindir}/letterize
35 %doc README COPYING
36
37 %changelog
38 * Wed Oct 20 2010 Eric S. Raymond <esr@snark.thyrsus.com> 1.3-1
39 - Polish to modern C, with like, #includes and everything.
40 - Change license to BSD.
41
42 * Mon Dec 29 2003 Eric S. Raymond <esr@snark.thyrsus.com> 1.2-1
43 - RPM packaging fixes for freshmeat release.
44
45 * Tue Jul 30 2002 Eric S. Raymond <esr@thyrsus.com>
46 - Initial build.
47
48
0 <?xml version="1.0" encoding="ISO-8859-1"?>
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
2 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
3 <!-- lifted from troff+man by doclifter -->
4 <refentry id='letterize.1'>
5 <refmeta>
6 <refentrytitle>letterize</refentrytitle>
7 <manvolnum>1</manvolnum>
8 <refmiscinfo class='date'>October 24, 1994</refmiscinfo>
9 <refmiscinfo class='productname'>letterize</refmiscinfo>
10 <refmiscinfo class='source'>letterize</refmiscinfo>
11 <refmiscinfo class='manual'>Miscellanea</refmiscinfo>
12 </refmeta>
13 <refnamediv id='name'>
14 <refname>letterize </refname>
15 <refpurpose> phone-number to letter-mnemonic generator</refpurpose>
16 </refnamediv>
17 <refsynopsisdiv id='synopsis'>
18
19 <cmdsynopsis>
20 <command>letterize</command> <arg choice='plain'><replaceable>nnnnnnn</replaceable></arg>
21 </cmdsynopsis>
22
23 </refsynopsisdiv>
24 <!-- body begins here -->
25
26 <refsect1 id='description'><title>DESCRIPTION</title>
27 <para>This program tries to help you find a letter mnemonic matching a
28 given phone number.</para>
29
30 <para>It emits to standard output each possible pronounceable mnemonic, one
31 per line, using the American standard mapping of dial letters to
32 numbers (2 goes to ABC, 3 to DEF, 4 to GHI, 5 to JKL, 6 to MNO, 7 to
33 PRS, 8 to TUV, 9 to XYZ).</para>
34
35 <para>The program uses a table of pronounceable letter-triples derived from
36 a dictionary scan. Each potential mnemonic must be such that all of
37 its letter-triples are in the table to be emitted. About 30% of
38 possible triples are considered pronounceable.</para>
39
40 <para>A typical 7-digit phone number has 19,683 possible mnemonics, but this
41 test usually cuts the list down to a few hundred or so, a reasonable
42 number to eyeball-check. For some numbers, the list will, sadly, be
43 empty.</para>
44
45 <para>It's best to leave out punctuation such as dashes and parens.</para>
46 </refsect1>
47
48 <refsect1 id='bugs'><title>BUGS</title>
49 <para>The filtering method doesn't know what plausible medial triples are
50 not reasonable at the beginnings and ends of words.</para>
51
52 <para>I'm not sure what table position 0 (which is what 0 and 1 are mapped
53 to) means. If you figure it out, you tell me. I really should have
54 generated my own table, but that would have been more work than this
55 seemed worth -- if your number contains either, you probably need
56 to generate your mnemonic in disjoint pieces around the digits anyway.</para>
57 </refsect1>
58
59 <refsect1 id='author'><title>AUTHOR</title>
60 <para>Eric S. Raymond <email>esr@snark.thyrsus.com</email>. It's
61 based on a table of plausible letter-triples that had no name attached
62 to it. Surf to <ulink
63 url='http://www.catb.org/~esr/'>http://www.catb.org/~esr/</ulink>
64 for updates and related resources.</para>
65
66 </refsect1>
67 </refentry>