Debian Codegraph @

man/trietool.1

raw
1 .\" Hey, EMACS: -*- nroff -*-
2 .\" First parameter, NAME, should be all caps
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 .\" other parameters are allowed: see man(7), man(1)
5 .TH TRIETOOL 1 "DECEMBER 2008"
6 .\" Please adjust this date whenever revising the manpage.
7 .\"
8 .\" Some roff macros, for reference:
9 .\" .nh disable hyphenation
10 .\" .hy enable hyphenation
11 .\" .ad l left justify
12 .\" .ad b justify to both left and right margins
13 .\" .nf disable filling
14 .\" .fi enable filling
15 .\" .br insert line break
16 .\" .sp <n> insert n+1 empty lines
17 .\" for manpage-specific macros, see man(7)
18 .SH NAME
19 trietool \- trie manipulation tool
20 .SH SYNOPSIS
21 \fBtrietool\fP [ \fIoptions\fP ] \fItrie command arg\fP ...
22 .SH DESCRIPTION
23 \fBtrietool\fP is the command-line tool for manipulating double-array trie
24 data. It can be used to query, add and remove words in a trie.
25 .P
26 .SS The Trie
27 The \fItrie\fP argument specifies the name of the trie to manipulate.
28 A trie is stored in a file with `.tri' extension. However, to create a new
29 trie, one needs to prepare a file with `.abm' extension, describing the
30 Unicode ranges of alphabet set of the trie. The ABM defines a set of
31 vectors that map Unicode characters into a continuous range of integers.
32 The mapped integers will be used as internal alphabet for the trie.
33 Such mapping can improve the space allocation within the trie data, regardless
34 of non-continuity of the character set being used, as the mapped range is
35 always continuous.
36 .P
37 The ABM file is a plain text file, with each line listing a range of 32-bit
38 Unicodes to be added to the alphabet set, in the format:
39 .IP
40 [0xSSSS,0xTTTT]
41 .P
42 where `0xSSSS' and `0xTTTT' are hexadecimal values of starting and ending
43 character code for the range, respectively.
44 .P
45 For example, for a dictionary that contains only English words witout any
46 punctuations, one may prepare `\fItrie\fP.abm' as:
47 .IP
48 [0x0041,0x005a]
49 .br
50 [0x0061,0x007a]
51 .P
52 The first line lists the ASCII codes for A-Z, and the second for a-z.
53 .P
54 No more than 255 alphabets are allowed in a trie.
55 .P
56 The created `.tri' file will incorporate the ABM data. So, the `.abm' file
57 is not required after the first creation, and will be ignored.
58 .SH COMMANDS
59 Available commands are:
60 .TP
61 \fBadd\fP \fIword data\fP ...
62 Add \fIword\fP to trie, associated with integer \fIdata\fP. Arbitrary number of
63 words-data pairs can be given. Two arguments will be read at a time, the first
64 will be treated as \fIword\fP, and the second as \fIdata\fP.
65 .TP
66 \fBadd-list\fP [ \fIoptions\fP ] \fIlist-file\fP
67 Add words with associated data listed in \fIlist-file\fP to trie. The
68 \fIlist-file\fP must be a text file listing one word per line. The associated
69 data can be put after the word in the same line, separated with tab (`\\t')
70 character. If the data field is omitted, a default value (\-1) will be used
71 instead.
72 .TP
73 .B " "
74 \fIOptions\fP are available for this command:
75 .RS
76 .TP
77 .B \-e, \-\-encoding \fIenc\fP
78 Specify character encoding of the \fIlist-file\fP contents, such as `UTF-8'.
79 If omitted, current locale codeset is assumed.
80 .RE
81 .TP
82 \fBdelete\fP \fIword\fP ...
83 Delete \fIword\fP from trie. Arbitrary number of words to delete can be given.
84 .TP
85 \fBdelete-list\fP [ \fIoptions\fP ] \fIlist-file\fP
86 Delete words listed in \fIlist-file\fP from trie. The \fIlist-file\fP must be
87 a text file listing one word per line.
88 .TP
89 .B " "
90 \fIOptions\fP are available for this command:
91 .RS
92 .TP
93 .B \-e, \-\-encoding \fIenc\fP
94 Specify character encoding of the \fIlist-file\fP contents, such as `UTF-8'.
95 If omitted, current locale codeset is assumed.
96 .RE
97 .TP
98 \fBquery\fP \fIword\fP
99 Search for \fIword\fP in trie. If \fIword\fP exists, its associated data
100 is printed to standard output. Otherwise, error message is printed to standard
101 error, with nothing printed to standard output.
102 .TP
103 \fBlist\fP
104 List all words in trie to standard output. The output lists one word-data pair
105 per line, separated with tab (`\\t') character, the format appropriate for
106 being \fIlist-file\fP for the \fBadd-list\fP command.
107 .SH OPTIONS
108 This program follows the usual GNU command line syntax, with long
109 options starting with two dashes (`\-\-').
110 A summary of options is included below.
111 .TP
112 .B \-p, \-\-path \fIdir\fP
113 Set trie directory to \fIdir\fP [default=`.']
114 .TP
115 .B \-h, \-\-help
116 Show summary of options.
117 .TP
118 .B \-V, \-\-version
119 Show version of program.
120 .SH AUTHOR
121 libdatrie was written by Theppitak Karoonboonyanan.
122 .PP
123 This manual page was written by Theppitak Karoonboonyanan <[email protected]>.