Indexing a database by finite-state transducer

Abstract: A technique of using the path numbers of an acyclic finite-state transducer as a method of indexing a database. Each entry in the database has associated therewith one or more keys. The method of indexing the database comprises: providing a finite state transducer defining the keys for the database; for each key, determining a path number associated with that key, said path number defining a mapping between that key and the or each corresponding entry in the database.

Description: The present invention relates to data processing, and more particularly to a technique of indexing a database using the path numbers of an acyclic finite-state transducer (FST). In the following, an index refers to a device that associates alphanumeric keys with one or more addresses in a database. If the database is a physical object, such as a book, the index might be a list of pairs consisting of a keyword or a phrase and a list of numbers identifying the pages where the word or phrase appears in the book. If the database is an electronic document, such as a machine readable dictionary , the index might be a list of pairs that consist of a headword of a dictionary entry as a key, and a list of locations in a computer file or in the memory of the computer where the entry is stored. For a computerised index, it is important to have an efficient method of computing the address corresponding to a key. The construction of a hash table is a well known way to achieve this purpose. It involves (a) selecting a function that assigns to each key some random numerical value in a chosen range and (b) storing the address associated with the key in the corresponding location in the hash table. The standard hashing method can be suboptimal in two ways: (1) the hash function may assign the same value to more than one key, and (2) some values are not assigned to any key at all. Because of (1), the address must be marked in some way to make it possible to determine which key they belong to; and (2) means that the hash table may be partially empty. If (1) or (2) holds, some space, and possibly search time, is wasted. Word/number mapping Both of the aforementioned problems can be avoided by finding a hash function that assigns to each key a unique value in a range that exactly matches the size of the hash table. This guarantees that every position in the table is filled with one and only one address; thus, it is not necessary to mark which key each address belongs to. A perfect hash function of this type can be obtained by constructing a deterministic finite-state automaton that enumerates the keys. C. L. Lucchesi and T. Kowalski ("Applications of Finite Automata Representing Large Vocabularies", Software Practice and Experience, Vol. 23(1), pp. 15-30, January 1993) describe an algorithm that associates a unique number with every word accepted by a deterministic finite-state automaton. The numbers range from 0 to n-1, where n is the number of words accepted by the automaton. Because the size of the hash table can be the same as the number of keys, no space is wasted. However, in some cases of database access even such a perfect hash function is not appropriate because (1) it assigns, by definition, to each key exactly one value and because (2) every value is associated with only one key. There are databases and applications for which neither (1) nor (2) is desirable. An example of that kind is an online dictionary. To illustrate a case in which it is desirable to provide multiple values for some keys, in the following description we will consider a simple example: searching for the location of the entry for the word "do" in an English dictionary. Published European patent application EP-A-649,105 discloses a technique in which a stored word list can be used for word-to-number (WIN) and number-to-word (N/W) mapping. Each word in the list can be mapped to a unique number within a dense set of numbers ranging from zero to one less than the total number of words in the list. Some branches of the data structure can be skipped during mapping because of branching information associated with branch points. The branching information permits mapping to continue with a next branch or with an alternative branch. The branching information indicates the number of suffix endings in the next branch; this number is used to keep a count of the word endings during W/N mapping; it is also used both to determine whether to continue with the next branch and also to reduce the number being mapped during N/W mapping. The branching information can include a full length pointer to the next branch or a shorter length pointer index to a table in which the full length pointer is stored. In either case, the number of suffix endings in the next branch can be annexed to the pointer. Where sublists of words have identical suffixes, the suffixes can be collapsed into shared branches. A typical dictionary does not provide a unique headword for each entry. Many words, including "do", appear as a headword in several entries. There is one entry for "do" in the sense of an activity, another entry for "do" as a note on a musical scale. Consequently, the query for the address of "do" should yield multiple answers: one for each entry with "do" as the headword. The previous example assumes that user does not know in advance that "do" can be both a verb and a noun. But this is not necessarily true. In a sentence like "I want to do something," the occurrence of "do" can be easily identified as a verb. In this context, only the entry or entries concerned with the verb sense of "do" are relevant. The user should be able to narrow the query, say, to "do+V", thereby receiving only a pointer to the verb entry of "do" as the answer. (We use the symbol "+V" to refer to verbs, "+N" for nouns.) The present invention solves problems of this type while retaining the advantages of the Lucchesi-Kowaltowski perfect hash function. The essence is to index a database by means of a finite-state transducer. The present invention provides a method of indexing a database, each entry in the database having associated therewith one or more keys, comprising: (a) providing a finite-state transducer defining the keys for the database; (b) for each key, determining at least a path number associated with that key, said path number defining a mapping between that key and the or each corresponding entry in the database. The invention further provides a method of retrieving an entry in a database, the database having been indexed according to the abovementioned method, comprising: (d) receiving a key input by a user; (e) determining the or each path number associated with the key; and (f) retrieving the entry corresponding to the or each path number determined in step (e). In each case, the database preferably comprises an electronic dictionary, and the or each said key comprises a headword in the dictionary, a headword associated with an additional marker or markers, such as a part-of-speech tag, sense number target language indicator, or any other characteristic that may be used to distinguish among different types of information associated with the same headword. In step (d), the input key may include an indication as to whether it is an upper-side (L1) or lower-side (L2) word. Step (e) may include the step (el) of matching the input key against the corresponding side word of the transducer. The invention further provides a programmable data processing apparatus when suitably programmed for carrying out the method of any of claims 1 to 8 of the appended claims, or according to any of the particular embodiments described herein. The invention uses the path numbers of an acyclic finite-state transducer as a method of indexing a database. The use of a transducer rather than a simple network makes it possible to associate a search key with multiple values and to assign the same value to multiple keys while retaining all the advantages of word-number mapping (as disclosed in the above-mentioned EP-A-649,105 and Lucchesi and Kowaltowski references). This flexibility is important for applications such as the accessing of entries in an electronic dictionary. Embodiments of the invention will now be described, by way of example, with reference to the accompanying drawings, in which: Figure 1 shows a simple example of a finite-state transducer used to describe the invention; Figure 2 illustrates the path for the pair <do+V,do> in Fig.1; Figure 3 shows the network of Fig.1 after the numbers have been determined for each state therein; Figure 4 illustrates the calculation that assigns to one of the paths in Fig.3 a path number; Figure 5 shows a general outline of a server used to implement the invention with an electronic dictionary; Figure 6 presents schematic flow diagrams of the processes used to implement the invention on a conventional computer; and Figure 7 is a schematic block diagram of a computer which may be used to implement the present invention. As will be apparent to persons skilled in the art, the present invention may be implemented by means of a suitably programmed conventional computer, such as, for example, a minicomputer running Unix®, or a PC running DOS®/Windows™. The details of such hardware are given at the end of this disclosure, with reference to Fig. 7. Assigning Number to Keywords with a Transducer A finite-state transducer is a network of states and arcs that defines a relation between two regular languages L1 and L2. Each word in L1 is mapped to one or more words in L2, and vice versa. We assume in the following that the mapping is done in a non-redundant fashion. That is, the symbols of the L1 word are associated with the symbols of the L2 word from left to right, padding the shorter string, if necessary, with epsilon symbols at the end to make the words be of equal length. Although any word in L1 and L2 may appear on several paths of the transducer, for any pair of words from L1 and L2 that are mapped to each other, there is a unique path through the network. Thus it is possible to assign a unique index (number) to every pair of words in the relation. (The use of finite state transducers is discussed, in the context of text indexing and retrieval, in detail in EP-A-583,083). Figure 1 presents a simple example of a finite-state transducer used to describe the invention. The network in Figure 1 encodes the relation R shown in Table 1. L1={cab, can+N, can+V, do+N, do+V, dud} L2={cab, can, do, dud} R={<cab, cab>, <can+N, can>, <can+V, can>, <do+N, do>, <do+V, do>, <dud, dud>} Each pair in the relation R inTable 1 is represented in the network of Figure 1 by a path of arcs that leads from the initial state on the left to the final state (marked with a double circle) on the right. The arcs are labelled by a pair of symbols, the upper member is a symbol from the alphabet of L1, the lower member a symbol from the alphabet of L2. One of the two symbols may be the special null symbol _ (=epsilon). The pair <do+V, do> for example, corresponds to the path shown in Figure 2. With the transducer in Figure 1, any L2 word, such as "do", can be mapped to its counterparts in L1, "do+N" and "do+V" by finding all paths such as the one in Figure 2 that have the symbol sequence of the L2 word, "d" "o" in this case, on the lower side, possibly followed by epsilons. The corresponding L1 word is represented by the symbol sequence on the upper side, ignoring trailing epsilons. The procedure for mapping an L1 word to its counterparts in L2 is exactly the same except that the upper side of the arc labels is used in the match and the output is produced from the lower side. The simple method of finding the paths that represent an L1 or L2 word can be augmented to associate each path with a unique number. As a preliminary step, in each state of the network is recorded the number of paths from that state to a final state. The result is displayed in Figure 3. The number recorded in each state is equal to the sum of numbers at the destination states of the arcs that lead away from the state (plus 1 if the state is final). The computation of the path numbers is based on the ordering of the outgoing arcs and the numbers at the destination states of those arcs. At the initial state, the path number is zero. If the chosen arc is not the first (= topmost) arc of the state where it originates, the path number is increased by the destination numbers of all the earlier arcs. The number of a given path can thus be determined simply by computing the sum of the destination numbers of all the arcs that precede the selected arc in each state along the path. Figure 4 illustrates the calculation that assigns to the path in Figure 2 the number 4. Note that the L2 word "do" is associated with two paths in the network in Figure 3, path 4 and path 3, whereas the L1 word "do+V" has a unique number, 4, in the network since it only appears on the path shown in Figures 2 and 4. In an application that lets the user to access a database to obtain information about the words in the network, the addresses of the two entries for "do" would be stored in cells 3 and 4 of a six cell matrix associated with the network. A query that uses the lower side of the network to access the data returns pointers for two entries for "do" and "can", and to single entries for "cab" and "dud". The upper side of the network allows the use to access the database by specifying a headword and a part of speech. Application: Indexing an Electronic Dictionary The method has been implemented to provide access to online electronic dictionaries for English and French, each containing about 40K entries. Figure 5 gives a general outline of the dictionary server. When the server is launched, it reads the online dictionary (a 17 MB text file) and constructs two data structures: a headword transducer of the type described in the preceding section and a file position map that stores the addresses of all the entries in the dictionary. The client application can send two types of queries: (1) just a headword or (2) headword and a part-of-speech indicator (e.g., "+V", "+N"). The server computes the path number or numbers associated with the input and returns the corresponding address or addresses in the file position map. Figure 6 shows schematic flow diagrams of the processes used (a) by the server, and (b) by the client, to implement on a conventional computer the embodiment of the present invention mentioned in the preceding discussion. Referring to Fig. 6(a), the online dictionary is initially read from storage (step s1). Then, the finite-state transducer is constructed as discussed above, with one path being provided for each entry in the dictionary (step s2). A routine for assigning a state number to each state in the FST is performed at step s3. To each state is assigned a number indicating the number of paths from that state to a final state. This process is recursive and starts from the initial (leftmost) state. Initially, a preliminary pass is made through the transducer setting all state numbers to zero. Then, the following recursive routine is called on the initial state of the network. (This routine presupposes that the network is acyclic.) Assume here that STATE.number refers to the number associated with the state (initially 0); and STATE.final is a flag that indicates whether the state is a final state. A state consists of a number of arcs departing therefrom. Each arc has a label (not needed here) and a destination state. ARC.destination refers to the destination state of the arc. When the routine is called on the initial state of the network, it checks if the state number is zero. If it is not zero, the state has already been processed and the function simply returns the previously computed value. If the state has not been processed, i.e. if the state number is still zero, there is work to be done. If the state is a final state, STATE.number is set to 1, otherwise it remains 0. In the next step, the routine calls itself on the destination states of all the arcs leaving the state in question and increments the STATE.number with the values returned by these function calls. Finally, the computed value is returned. Subsequently, a file position map is constructed. At step s4, the first entry in the dictionary is fetched. The key (i.e. headword in the dictionary) for the current entry is extracted at step s5, and the corresponding address in the dictionary stored. Next, at step s6, using the key as an L1 word, the path number for the key is obtained from the FST. The path number and corresponding dictionary address are then stored in the file position map at step s7. A check is made at step s8 as to whether the path number and address for all entries in the dictionary have been stored. If not, the process increments to the next entry (step s9) and returns to step s5, otherwise the process is concluded. The process for retrieving an entry in response to an input query is illustrated in Fig. 6 (b). First a check is made that a valid query input has been received (step s10); for example, non-character inputs may be ignored. Then, suitably by extracting the final string portion of the input query and comparing it with a list of possibilities (e.g., "+V", "+N") it is determined (step s11) whether the input includes a part of speech indicator. If it does, the query is matched at step s12 against the upper side (L1 words) of the FST in order to obtain the corresponding path number in the FST. If the input query does not include a part of speech indicator, the query is matched at step s13 against the lower side (L2 words) of the FST to obtain the path number or numbers for each possible path through the FST. In the example discussed earlier, this returns paths numbers 4 and 3 for the input word "do", corresponding to the paths for "do+V" and "do+N", respectively, in L1. Next, the path numbers thus obtained are used to extract (step s14) the corresponding address(es) from the file position map (see Fig. 5). Thereafter the entries at those address(es) are retrieved and displayed (step s15). It will be appreciated that if the input query gives rise to no valid address from the FST, a suitable message may be displayed to the effect that no entry exists for the query word entered. The above-described transducer method of indexing a database has potential applications in many other domains besides the simple example given here. It can also be extended from simple transducers to automata that encode n-level relations, thus providing any number of ways to efficiently access a database. Figure 7 shows schematically the hardware of the computer employed in accordance with one preferred embodiment of the invention. The configuration is well known to persons skilled in the art and is described in detail in, for example, The Art of Electronics, 2nd Edn, Ch. 10, P. Horowitz and W. Hill, Cambridge University Press, 1989. Stated briefly, the system comprises, connected to common bus 30, a central processing unit 32, memory devices including random access memory (RAM) 34, read only memory (ROM) 36 and disk, tape or CD-ROM drives 38, keyboard 12, mouse 14, printing, plotting or scanning devices 40, and A/D, D/A devices 42 and digital input/output devices 44 providing interfacing to external devices 46. The computer may be equipped with a conventional internal driver card (not shown) and appropriate software (such as Netware, available from Novell Corp.) enable the computer to form part of a local area network (LAN), as is well known in the art.

Claims: A method of indexing a database, each entry in the database having associated therewith one or more keys, comprising: (a) providing a finite-state transducer defining the keys for the database; (b) for each key, determining at least a path number associated with that key, said path number defining a mapping between that key and the or each corresponding entry in the database. A method according to claim 1, further comprising the step (c) of generating a file position map defining the address, in the database, of each of said entries and wherein each entry in said file position map is associated with one of said path numbers. A method according to claim 1 or 2, wherein step (b) comprises: (b1) for each state in the finite-state transducer, associating a state number with that state, said state number equating to the number of paths of any length (including zero) from that state to a final state. A method according to claim 3, wherein step (b) comprises: (b2) for each path in the finite state transducer, determining a path number, associated with that path, as a function of the destination state numbers of the arcs originating in the states along that path. A method of retrieving an entry in a database, the database having been indexed according to the method of any of the preceding claims, comprising: (d) receiving a key input by a user; (e) determining the or each path number associated with the key; and (f) retrieving the entry corresponding to the or each path number determined in step (e). A method according to claim 5, wherein step (f) comprises: (f1) obtaining, for the or each path number determined in step (e), the corresponding address in said file position map. A method according to claim 6, wherein step (f) comprises: (f2) retrieving the database entry at the or each address obtained in step (f1). A method according to any of the preceding claims, wherein said database comprises an electronic dictionary, and preferably wherein the or each said key comprises a headword in the dictionary, a headword associated with an additional marker or markers, such as a part-of-speech tag, sense number or target language indicator. A programmable data processing apparatus when suitably programmed for carrying out the method of any of the preceding claims, the apparatus comprising a processor, memory, input/output circuitry and a user interface.

Inventors: KARTTUNEN LAURI, KARTTUNEN, LAURI
Applicants: XEROX CORP, XEROX CORPORATION
Application year: 1996
Main classification: G06F17
IPC codes: G06F17