Debian Codegraph @

docs/manual/WordList.html

raw
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>WordList</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 WordList
13 </b></font></table></table>
14 <p>One of the <a href="Types_of_objects.html">types of objects</a> in Praat. An object of class WordList contains a sorted list of strings in a system-independent format. WordList objects can be used for spelling checking after conversion to a <a href="SpellingChecker.html">SpellingChecker</a> object.</p>
15 <h2>1. How to create a WordList object</h2>
16 <p>You will normally create a WordList object by reading a binary WordList file. You'll use the generic <a href="Read_from_file___.html">Read from file...</a> command from the <b>Open</b> menu.</p>
17 <p>See below under 3 for how to create such a file.</p>
18 <h2>2. What you can do with a Wordlist object</h2>
19 <p>The main functionality of a WordList is its ability to tell you whether it contains a certain string. If you select a WordList, you can query the existence of a specific word by using the <b>Has word</b> command. You supply the word and press OK. If the WordList does contain the word, the value "1" will be written to the Info window; otherwise, the value "0" will be written.</p>
20 <h2>3. How to create a binary WordList file</h2>
21 <p>You can create a binary WordList file from a simple text file that contains a long list of words. Perhaps such a text file has been supplied by a lexicographic institution in your country; because of copyright issues, such word lists cannot be distributed with the Praat program. To convert the simple text file into a compressed WordList file, you basically take the following steps:</p>
22 <code> Read Strings from raw text file: "lexicon.txt"<br></code>
23 <code> Sort<br></code>
24 <code> To WordList<br></code>
25 <code> Save as binary file: "lexicon.WordList"<br></code>
26 <p>I'll explain these steps in detail. For instance, a simple text file may contain the following list of words:</p>
27 <code> cook<br></code>
28 <code> cooked<br></code>
29 <code> cookie<br></code>
30 <code> cookies<br></code>
31 <code> cooking<br></code>
32 <code> cooks<br></code>
33 <code> Copenhagen<br></code>
34 <code> København<br></code>
35 <code> München<br></code>
36 <code> Munich<br></code>
37 <code> ångström<br></code>
38 <p>These are just 11 words, but the procedure will work fine if you have a million of them, and enough memory in your computer.</p>
39 <p>You can read the file into a <a href="Strings.html">Strings</a> object with <a href="Read_Strings_from_raw_text_file___.html">Read Strings from raw text file...</a> from the <b>Open</b> menu in the Objects window. The resulting <a href="Strings.html">Strings</a> object contains 11 strings in the above order, as you can verify by viewing them with <a href="Inspect.html">Inspect</a>.</p>
40 <p>If you select the Strings, you can click the <b>To WordList</b> button. However, you will get the following complaint:</p>
41 <code> String "Copenhagen" not sorted. Please sort first.<br></code>
42 <p>This complaint means that the strings have not been sorted in Unicode sorting order. So you click <b>Sort</b>, and the Strings object becomes:</p>
43 <code> Copenhagen<br></code>
44 <code> København<br></code>
45 <code> Munich<br></code>
46 <code> München<br></code>
47 <code> cook<br></code>
48 <code> cooked<br></code>
49 <code> cookie<br></code>
50 <code> cookies<br></code>
51 <code> cooking<br></code>
52 <code> cooks<br></code>
53 <code> ångström<br></code>
54 <p>The strings are now in Unicode sorting order, in which capitals come before lower-case letters, and composite characters follow the latter.</p>
55 <p>Clicking <b>To WordList</b> now succeeds, and a WordList object appears in the list. If you save it to a text file (with the Save menu), you will get the following file:</p>
56 <code> File type = "ooTextFile"<br></code>
57 <code> Object class = "WordList"<br></code>
58 <code> <br></code>
59 <code> string = "Copenhagen<br></code>
60 <code> København<br></code>
61 <code> Munich<br></code>
62 <code> München<br></code>
63 <code> cook<br></code>
64 <code> cooked<br></code>
65 <code> cookie<br></code>
66 <code> cookies<br></code>
67 <code> cooking<br></code>
68 <code> cooks<br></code>
69 <code> ångström\" <br></code>
70 <p>Note that any double quotes (") that appear inside the strings, will be doubled, as is done everywhere inside strings in Praat text files.</p>
71 <p>After you have created a WordList text file, you can create a WordList object just by reading this file with <a href="Read_from_file___.html">Read from file...</a> from the <b>Open</b> menu.</p>
72 <p>The WordList object has the advantage over the Strings object that it won't take up more memory than the original word list. This is because the WordList is stored as a single string: a contiguous list of strings, separated by new-line symbols.</p>
73 <hr>
74 <address>
75 <p>© ppgb 20190616</p>
76 </address>
77 </body>
78 </html>