JP2010225156A - Apparatus and program for collating character string - Google Patents

Apparatus and program for collating character string Download PDF

Info

Publication number
JP2010225156A
JP2010225156A JP2010071824A JP2010071824A JP2010225156A JP 2010225156 A JP2010225156 A JP 2010225156A JP 2010071824 A JP2010071824 A JP 2010071824A JP 2010071824 A JP2010071824 A JP 2010071824A JP 2010225156 A JP2010225156 A JP 2010225156A
Authority
JP
Japan
Prior art keywords
state
transition
character
nfa
state transition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2010071824A
Other languages
Japanese (ja)
Other versions
JP5077380B2 (en
Inventor
Mitsunori Kori
光則 郡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2010071824A priority Critical patent/JP5077380B2/en
Publication of JP2010225156A publication Critical patent/JP2010225156A/en
Application granted granted Critical
Publication of JP5077380B2 publication Critical patent/JP5077380B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To reduce a memory capacity required for storing a state transition table for the collation of a character string, having regular expression as a collation condition. <P>SOLUTION: A character string collation apparatus includes: a state transition table generator 3 for generating the state transition table, based on a collation condition 2 described with regular expression; and an automaton that shifts based on the state transition table generated by the state transition table generator 3. In the state transition table generated on the basis of the collation condition 2, when a next shift destination state relative to the set of the present state and an input character does not exist, the automaton shifts to either an initial state or a predetermined state, without proceeding to reading the input character. Thus, the memory capacity required for storing the state transition table is reduced. In the state transition table generated based on the collation condition 2, when the next shift destination state relative to the set of the present state and the input character does not exist, the state transition table is generated by setting an exclusion character for shifting to the predetermined state without proceeding to reading the input character. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、正規表現によって指定されたパターンと文章中のテキストの照合を行うための技術に関するものである。   The present invention relates to a technique for collating a pattern designated by a regular expression with text in a sentence.

近年様々な分野で文書の電子化が進んでおり、文書の効率的な検索方法が求められている。検索の一方法として、正規表現によって指定されたパターンと文書中のテキストの照合を行う方法がある。正規表現とは、例えば非特許文献1に記載されており、正規言語と呼ばれる言語のクラスを表現する表記方法である。正規表現を検索条件とする文字列照合方式として、DFA(Deterministic Finite Automaton、決定性有限オートマトン)による方法が知られている。   In recent years, the digitization of documents is progressing in various fields, and an efficient document search method is required. As a search method, there is a method of matching a pattern specified by a regular expression with text in a document. The regular expression is described in, for example, Non-Patent Document 1, and is a notation method for expressing a class of a language called a regular language. As a character string matching method using a regular expression as a search condition, a method using DFA (Deterministic Finite Automaton) is known.

DFAによる文字列照合方式は状態遷移機械(オートマトン)のモデルに基づいている。状態遷移機械は内部に状態と状態遷移関数を持つ。状態遷移関数は現在の状態と入力文字に対して次の状態を決定する関数である。DFAを用いた文字列照合方式では、入力テキストを1文字づつ読み出し、現在の状態と入力文字の組に対して状態遷移関数を適用して得られた次の状態に遷移する。この方法によるとテキストを後戻りすることなく1度走査することによって照合を行うことができ、高速な文字列照合が可能になる。複数の条件による照合を行う場合、照合に成功した条件を区別するため、DFAを拡張し各状態に出力を定義した出力つき有限オートマトン(Moore機械)も用いられている。   The string matching method by DFA is based on a model of state transition machine (automaton). The state transition machine has a state and a state transition function inside. The state transition function is a function that determines the next state for the current state and the input character. In the character string matching method using DFA, the input text is read one character at a time, and a transition is made to the next state obtained by applying the state transition function to the set of the current state and the input character. According to this method, it is possible to perform collation by scanning the text once without going back, and high-speed character string collation is possible. When collating with multiple conditions, a finite automaton with output (Moore machine) that extends DFA and defines the output for each state is also used to distinguish the conditions that succeeded in collation.

DFAの状態遷移関数は照合条件となる正規表現によって決まるが、従来から、正規表現を一度NFA(Non-deterministic Finite Automaton、非決定性有限オートマトン)に変換し、更にNFAをDFAに変換するその手順が知られており、例えば非特許文献1などに記載されている。DFAによる文字列照合方式は高速であるという特長を持つが、反面、DFAの状態遷移関数を実現するための状態遷移表が巨大になりやすいという欠点があった。   The DFA state transition function is determined by the regular expression that is the matching condition. Conventionally, the regular expression is once converted to NFA (Non-deterministic Finite Automaton), and the procedure to convert NFA to DFA For example, it is described in Non-Patent Document 1. The DFA character string matching method has a feature that it is fast, but on the other hand, there is a drawback that the state transition table for realizing the DFA state transition function tends to be huge.

一例として、特許文献3に開示されている図52の照合条件を例にとる。図53は従来の出力つき有限オートマトンにおいて図52の照合条件から生成される状態遷移表および失敗関数である。このように状態数18と文字種別5種類に対し、90通りの組を保持する状態遷移表を生成する必要がある。   As an example, the collation condition of FIG. 52 disclosed in Patent Document 3 is taken as an example. FIG. 53 shows a state transition table and a failure function generated from the matching condition of FIG. 52 in the conventional finite automaton with output. Thus, it is necessary to generate a state transition table that holds 90 combinations for the number of states 18 and the five types of characters.

このような課題を解決する方法として、特許文献1、特許文献2には、AC(Aho-Corasick)法に基づく状態遷移表をDFAに変換した後、初期状態への遷移操作および初期状態の次の状態への遷移操作を状態遷移表から除去することによって状態遷移表の記憶容量を削減する方法が示されている。しかし、特許文献1、特許文献2に示された文字列照合方法では、照合の対象を固定の文字列キーワードに限定しているため、一般の正規表現を照合の対象とすることはできない。   As a method for solving such a problem, Patent Document 1 and Patent Document 2 describe that a state transition table based on the AC (Aho-Corasick) method is converted to DFA, then a transition operation to the initial state and the next of the initial state. A method of reducing the storage capacity of the state transition table by removing the transition operation to the state from the state transition table is shown. However, in the character string matching methods shown in Patent Document 1 and Patent Document 2, since the object of collation is limited to fixed character string keywords, general regular expressions cannot be the object of collation.

また、特許文献3には、DFAにおいて、失敗関数を定義することによって状態遷移表を削減する方法が示されている。しかし、特許文献3に示された方法では、一度失敗関数によって遷移した状態で再び遷移に失敗することがある。すなわち、遷移の失敗が連鎖的に発生することがある。このような場合は、繰り返し失敗関数を参照する必要があり照合速度が低下するという問題点があった。   Patent Document 3 discloses a method for reducing state transition tables by defining a failure function in DFA. However, in the method disclosed in Patent Document 3, there is a case where the transition fails again in a state where the transition is once performed by the failure function. That is, transition failures may occur in a chain. In such a case, there is a problem in that it is necessary to refer to the failure function repeatedly and the collation speed is reduced.

一例として、特許文献3に開示されている図52の照合条件を例にとる。図54は図52の照合条件から生成される状態遷移表および失敗関数であり、特許文献3に開示されている。   As an example, the collation condition of FIG. 52 disclosed in Patent Document 3 is taken as an example. FIG. 54 shows a state transition table and a failure function generated from the matching conditions shown in FIG.

照合条件が図52の条件であり、入力文字列が「aaca」の場合を例にとる。   For example, the collation condition is the condition of FIG. 52 and the input character string is “aaca”.

特許文献3に開示されている方法では、まず、状態を状態1に初期化する。次にまず、1文字目の「a」を読み、状態遷移表の状態1の行で入力文字「a」の列に示されている状態3に遷移する。次に、2文字目の「a」を読み、同様に、状態3から状態6に遷移する。次に3文字目の「c」を読むことにより、状態6から状態10に遷移する。ところが、次に4文字目の文字「a」が出現した場合は、状態10で文字「a」に該当する遷移先が存在しないことから、まず、状態10の失敗時の遷移先である状態5に遷移する。更に、状態5で文字「a」に該当する遷移先が存在しないことから、状態5の失敗時の遷移先である状態2に遷移する。しかし、状態2でも文字「a」に該当する遷移先が存在しないことから、状態2の失敗時の遷移先である状態1に遷移する。状態1では、文字「a」に該当する遷移先状態3が存在することから状態3に遷移する。このように、4文字目の入力文字に対しては合計4回の状態遷移表の参照と状態遷移を行っており、全体としては4文字の入力文字に対して、7回の状態遷移を必要とする。このように、特許文献3の方法では、状態遷移の失敗を繰り返し、その都度失敗時の遷移先を参照する動作が必要になる場合がある。このため、状態遷移表の参照回数が増加し、照合性能が低下すると言う問題点があった。   In the method disclosed in Patent Document 3, the state is first initialized to state 1. Next, the first character “a” is read, and the state transitions to state 3 indicated in the column of input character “a” in the state 1 row of the state transition table. Next, the second character “a” is read, and similarly, the state 3 is changed to the state 6. Next, the state 6 is changed to the state 10 by reading the third character “c”. However, when the next character “a” appears, since there is no transition destination corresponding to the character “a” in state 10, first, state 5 that is the transition destination at the time of failure of state 10 Transition to. Further, since there is no transition destination corresponding to the character “a” in the state 5, the state transitions to the state 2 that is the transition destination when the state 5 fails. However, since there is no transition destination corresponding to the character “a” even in the state 2, the state transitions to the state 1 that is the transition destination when the state 2 fails. In state 1, there is a transition destination state 3 corresponding to the character “a”, so transition is made to state 3. In this way, the state transition table is referenced and state transitions are made four times in total for the fourth input character, and seven state transitions are required for the four input characters as a whole. And As described above, in the method of Patent Document 3, it is sometimes necessary to repeat the state transition failure and refer to the transition destination at the time of the failure each time. For this reason, there has been a problem that the number of times the state transition table is referenced increases and collation performance deteriorates.

E.J.Hopcroft, D.J.Ullman, "Formal Languages and their Relation to Automata", Addison Wesley (1969)E.J.Hopcroft, D.J.Ullman, "Formal Languages and their Relation to Automata", Addison Wesley (1969) 特開2004-103035号公報JP 2004-103035 A 特開2004-103034号公報JP 2004-103034 A 特許第2994926号公報Japanese Patent No. 2994926

この発明は上記の問題点を解決するためになされたもので、正規表現を照合条件とする文字列照合に対して、状態遷移表を格納するのに必要な記憶容量を削減することを目的とする。   The present invention has been made to solve the above-described problems, and aims to reduce the storage capacity required to store a state transition table for character string matching using a regular expression as a matching condition. To do.

また、遷移の失敗による状態遷移表の参照回数を1文字当り2回以下とし、遷移の失敗が繰り返されることによる性能低下による性能低下を防止し、高速な文字列照合を可能にすることを目的とする。   In addition, the number of times the state transition table is referred to due to failure of transition is set to 2 or less per character to prevent performance degradation due to performance degradation due to repeated failure of transition and to enable high-speed character string matching And

本発明にかかわる文字列照合装置は、正規表現で記述された照合条件に基づいて状態遷移表を生成する状態遷移表生成部と、前記状態遷移表生成部により生成された状態遷移表に基づいて遷移するオートマトンとを備えるとともに、前記オートマトンは、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、入力文字を読み進めずに初期状態へ遷移するものである。   A character string matching device according to the present invention is based on a state transition table generating unit that generates a state transition table based on a matching condition described by a regular expression, and a state transition table generated by the state transition table generating unit. The automaton does not read the input character when there is no next transition destination state for the set of the current state and the input character in the state transition table generated based on the matching condition. To the initial state.

正規表現で記述された照合条件に基づいて状態遷移表を生成する状態遷移表生成部と、前記状態遷移表生成部により生成された状態遷移表に基づいて遷移するオートマトンとを備えるとともに、前記オートマトンは、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、入力文字を読み進めずに初期状態へ遷移することにより、状態遷移表を格納するのに必要な記憶容量を削減することができる。   A state transition table generating unit that generates a state transition table based on a matching condition described in a regular expression; and an automaton that transitions based on the state transition table generated by the state transition table generating unit, and the automaton In the state transition table generated based on the collation condition, when there is no next transition destination state for the set of the current state and the input character, the state is determined by transitioning to the initial state without reading the input character. The storage capacity required to store the transition table can be reduced.

文字列照合装置の構成を示す説明図である。It is explanatory drawing which shows the structure of a character string collation apparatus. 照合条件2の構成を示す説明図である。It is explanatory drawing which shows the structure of the collation conditions 2. FIG. 条件式17の構成を示す説明図である。FIG. 10 is an explanatory diagram showing a configuration of conditional expression 17; 状態遷移表生成部3の構成を示す説明図である。It is explanatory drawing which shows the structure of the state transition table production | generation part 3. FIG. 状態遷移表格納部4の構成を示す説明図である。It is explanatory drawing which shows the structure of the state transition table storage part. 出力表格納部5の構成を示す説明図である。4 is an explanatory diagram showing a configuration of an output table storage unit 5. FIG. 照合結果10の構成を示す説明図である。It is explanatory drawing which shows the structure of the collation result. 文字列照合装置の動作を示すフローチャートである。It is a flowchart which shows operation | movement of a character string collation apparatus. 照合条件のコンパイルの動作を示すフローチャートFlowchart showing verification condition compilation operation 初期状態への失敗遷移の追加の手続きを示すフローチャートFlow chart showing the procedure for adding failure transition to the initial state 初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)の手続きを示すフローチャートFlow chart showing the procedure for adding a failed transition to the initial state (when there is no transition destination due to σ any from the initial state) 初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)の手続きを示すフローチャートFlow chart showing the procedure for adding a failed transition to the initial state (when there is a transition destination by σ any from the initial state) 非決定的遷移の除去の手続きを示すフローチャートFlow chart showing the procedure for removing non-deterministic transitions 状態集合の初期化の手続きを示すフローチャートFlow chart showing the procedure for initializing the state set Σに関する非決定的遷移の除去の手続きを示すフローチャートFlow chart showing the procedure for removing non-deterministic transitions on Σ σotherに関する非決定的遷移の除去の手続きを示すフローチャートNon-deterministic transition removal procedure for σ other 新状態の生成の手続きを示すフローチャートFlow chart showing the procedure for creating a new state σotherによる状態遷移の補正の手続きを示すフローチャートFlow chart showing the procedure for correction of state transition by σ other 未使用状態の除去の手続きを示すフローチャートFlow chart showing the procedure for removing unused state 冗長状態の除去の手続きを示すフローチャートFlow chart showing procedure for removing redundant state 冗長な状態遷移の削除の手続きを示すフローチャートFlow chart showing the procedure for deleting redundant state transitions 状態遷移表と出力表の生成の手続きを示すフローチャートFlow chart showing the procedure for generating state transition table and output table 入力文書の照合の手続きを示すフローチャートFlow chart showing input document verification procedure メタキャラクタ「.」の置き換えを説明する説明図Explanatory drawing explaining replacement of metacharacter "." メタキャラクタ「^」の置き換えを説明する説明図Explanatory drawing explaining replacement of metacharacter "^" 初期状態へのε遷移を含むNFAを説明する説明図Explanatory drawing explaining NFA including ε transition to initial state ε遷移の省略を説明する説明図Explanatory drawing explaining omission of ε transition 失敗遷移の追加の必要な場合を説明する説明図Explanatory drawing explaining when failure transition needs to be added 失敗遷移の追加を説明する説明図Explanatory drawing explaining addition of failure transition 初期状態からσanyによる遷移が存在する場合を説明する説明図Explanatory drawing explaining the case where transition by σ any exists from the initial state 初期状態からσanyによる遷移が存在する場合の失敗遷移の追加を説明する説明図Explanatory drawing explaining the addition of the failure transition when transition by σ any exists from the initial state 非決定的遷移の除去(除去前)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (before removal) 非決定的遷移の除去(除去後)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (after removal) 非決定的遷移の除去(除去前)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (before removal) 非決定的遷移の除去(除去後)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (after removal) 非決定的遷移の除去(除去前)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (before removal) 非決定的遷移の除去(除去後)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (after removal) 非決定的遷移の除去(除去前)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (before removal) 非決定的遷移の除去(除去後)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (after removal) 非決定的遷移の除去(除去前)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (before removal) 非決定的遷移の除去(除去後)を説明する説明図Explanatory drawing explaining removal of non-deterministic transition (after removal) 冗長な状態遷移の削除を説明する説明図Explanatory drawing explaining deletion of redundant state transition 冗長な状態の併合を説明する説明図Explanatory drawing explaining merge of redundant states 照合条件の構成を示す説明図Explanatory drawing showing the configuration of verification conditions 状態遷移表の構成を示す説明図Explanatory diagram showing the structure of the state transition table 出力表の構成を示す説明図Explanatory diagram showing the structure of the output table 動作例を示す説明図Explanatory drawing showing an example of operation 照合条件の構成を示す説明図Explanatory drawing showing the configuration of verification conditions 状態遷移表の構成を示す説明図Explanatory diagram showing the structure of the state transition table 出力表の構成を示す説明図Explanatory diagram showing the structure of the output table 動作例を示す説明図Explanatory drawing showing an example of operation 特許文献3に開示されている照合条件Verification conditions disclosed in Patent Document 3 特許文献3による従来の出力付きDFAの状態遷移表State transition table of conventional DFA with output according to Patent Document 3 特許文献3による従来の状態遷移表と出力表Conventional state transition table and output table according to Patent Document 3

1 文字列照合装置
2 照合条件
3 状態遷移表生成部
4 状態遷移表格納部
5 出力表格納部
6 入力文書
7 入力文字読み取り部
8 SDFAオートマトン
9 状態記憶部
10 照合結果
11 状態遷移
12 出力記述
13 現状態
14 入力文字
15 次状態
16 条件番号
17 条件式
18 条件記述
21 状態遷移表生成制御部
22 NFA状態集合
23 NFA状態遷移集合
24 NFA出力記述集合
25 状態集合
26 状態遷移集合
27 出力記述集合
31 ハッシュ値計算部
32 ハッシュ値
33 状態遷移ハッシュポインタ
34 状態遷移ハッシュチェイン
35 状態遷移ハッシュ表
36 比較部
41 条件番号インデックス
42 条件番号チェイン
DESCRIPTION OF SYMBOLS 1 Character string collation apparatus 2 Collation conditions 3 State transition table production | generation part 4 State transition table storage part 5 Output table storage part 6 Input document 7 Input character reading part 8 SDFA automaton 9 State storage part 10 Collation result 11 State transition 12 Output description 13 Current state 14 Input character 15 Next state 16 Condition number 17 Conditional expression 18 Condition description 21 State transition table generation control unit 22 NFA state set 23 NFA state transition set 24 NFA output description set 25 State set 26 State transition set 27 Output description set 31 Hash value calculator 32 Hash value 33 State transition hash pointer 34 State transition hash chain 35 State transition hash table 36 Comparison unit 41 Condition number index 42 Condition number chain

実施例1.
図1はこの発明の文字列照合装置を示す構成図である。
Example 1.
FIG. 1 is a block diagram showing a character string collating apparatus according to the present invention.

図1において、文字列照合装置1は、この発明における正規表現による文字列照合を行う装置であり、入力文書6の中に照合条件2を満たすものが含まれるかどうかを照合結果10として出力する。照合条件2は文字列照合の条件を記述した条件であり、文字列照合装置1の入力となる。状態遷移表生成部3は照合条件2から状態遷移11と出力記述12を生成し、それぞれ状態遷移表格納部4、出力表格納部5に渡す。状態遷移表格納部は状態遷移11の組を保持する。出力表格納部5は出力記述12を保持する。入力文書6は照合の対象となる文書である。入力文字読み取り部7は入力文書6に含まれる文字を1文字づつ取り出し、入力文字14としてSDFAオートマトン8に送る。SDFAオートマトン8は内部の状態記憶部9に現状態13を記憶し、入力文字読み取り部7から入力文字14を受け取り、状態遷移表格納部4、出力表格納部5を参照して状態記憶部9に格納された現状態13の更新と照合結果10の出力を行う。状態記憶部9はSDFAオートマトン8の内部に保持された状態を記憶する。10は照合結果である。11は状態遷移であり、現状態13、入力文字14、次状態15の組である。12は出力記述であり、現状態13と条件番号16の組である。13は現状態である、14は入力文字である。15は次状態である。16は条件番号である。   In FIG. 1, a character string matching device 1 is a device that performs character string matching using a regular expression according to the present invention, and outputs as a matching result 10 whether or not the input document 6 includes a document that satisfies the matching condition 2. . The collation condition 2 is a condition describing a character string collation condition and is input to the character string collation apparatus 1. The state transition table generation unit 3 generates a state transition 11 and an output description 12 from the matching condition 2 and passes them to the state transition table storage unit 4 and the output table storage unit 5, respectively. The state transition table storage unit holds a set of state transitions 11. The output table storage unit 5 holds an output description 12. The input document 6 is a document to be collated. The input character reading unit 7 extracts characters included in the input document 6 one by one and sends them to the SDFA automaton 8 as input characters 14. The SDFA automaton 8 stores the current state 13 in the internal state storage unit 9, receives the input character 14 from the input character reading unit 7, and refers to the state transition table storage unit 4 and the output table storage unit 5 to refer to the state storage unit 9. The current state 13 stored in the table is updated and the collation result 10 is output. The state storage unit 9 stores the state held in the SDFA automaton 8. Reference numeral 10 denotes a collation result. Reference numeral 11 denotes a state transition, which is a set of a current state 13, an input character 14, and a next state 15. Reference numeral 12 denotes an output description, which is a set of a current state 13 and a condition number 16. 13 is the current state, and 14 is the input character. 15 is the next state. 16 is a condition number.

図2は、この発明における照合条件2の構成を示す図である。図において、条件式17は、照合条件2を構成する個別の条件であり、照合条件2の中に1または複数の条件式17が含まれる。   FIG. 2 is a diagram showing a configuration of collation condition 2 in the present invention. In the figure, the conditional expression 17 is an individual condition constituting the collation condition 2, and the collation condition 2 includes one or a plurality of conditional expressions 17.

図3は、この発明における条件式17の構成を示す図である。条件式17は、条件番号16と条件記述18から構成され、条件番号16は条件式を一意に区別するための番号であり、条件記述18は正規表現によって記述された照合の条件である。   FIG. 3 is a diagram showing the configuration of conditional expression 17 in the present invention. The conditional expression 17 includes a condition number 16 and a condition description 18. The condition number 16 is a number for uniquely distinguishing the conditional expression, and the condition description 18 is a matching condition described by a regular expression.

図4は、この発明における状態遷移表生成部3の構成を示す図である。図において、状態遷移表生成制御部21は、状態遷移生成表の生成の動作手順を制御する。NFA状態集合22、NFA状態遷移集合23、NFA出力記述集合24、状態集合25、出力遷移集合26、状態記述集合27は状態遷移表生成制御部21が参照するデータである。   FIG. 4 is a diagram showing a configuration of the state transition table generation unit 3 in the present invention. In the figure, a state transition table generation control unit 21 controls an operation procedure for generating a state transition generation table. The NFA state set 22, the NFA state transition set 23, the NFA output description set 24, the state set 25, the output transition set 26, and the state description set 27 are data to which the state transition table generation control unit 21 refers.

図5は、この発明における状態遷移表格納部4の構成の一例を示す図である。図において、31はハッシュ値計算部であり、現状態13と入力文字14からハッシュ値32を計算する。ハッシュ値32はハッシュ値計算部31によって計算されたハッシュ値である。状態遷移ハッシュポインタ33は状態遷移ハッシュチェイン34のポインタを複数格納する表である。状態遷移ハッシュチェイン34は状態遷移ハッシュチェイン34へのポインタ、現状態13、入力文字14、次状態15の組である。状態遷移ハッシュ表35は状態遷移ハッシュポインタ33と状態遷移ハッシュチェイン34から成るデータ構造である。比較部36は外部から入力された現状態13aと入力文字14aの組と、状態遷移ハッシュ表35に格納された現状態13b、入力文字14bを比較し、次状態15を出力する。   FIG. 5 is a diagram showing an example of the configuration of the state transition table storage unit 4 in the present invention. In the figure, reference numeral 31 denotes a hash value calculation unit, which calculates a hash value 32 from the current state 13 and the input character 14. The hash value 32 is a hash value calculated by the hash value calculation unit 31. The state transition hash pointer 33 is a table that stores a plurality of pointers of the state transition hash chain 34. The state transition hash chain 34 is a set of a pointer to the state transition hash chain 34, a current state 13, an input character 14, and a next state 15. The state transition hash table 35 has a data structure including a state transition hash pointer 33 and a state transition hash chain 34. The comparison unit 36 compares the set of the current state 13a and the input character 14a input from the outside with the current state 13b and the input character 14b stored in the state transition hash table 35, and outputs the next state 15.

図6は、この発明における出力表格納部5の構成を示す図である。条件番号インデックス41は条件番号チェインへのポインタを複数格納する。条件番号チェイン42は、条件番号チェイン42へのポインタと条件番号16の組である。   FIG. 6 is a diagram showing the configuration of the output table storage unit 5 in the present invention. The condition number index 41 stores a plurality of pointers to the condition number chain. The condition number chain 42 is a set of a pointer to the condition number chain 42 and the condition number 16.

図7は、この発明における照合結果10の一例を示す図である。照合結果10には、入力文書6の照合に成功した条件番号16が含まれる。   FIG. 7 is a diagram showing an example of the collation result 10 in the present invention. The matching result 10 includes a condition number 16 that has been successfully matched with the input document 6.

次に、本発明の動作説明に先立ち、以下の説明で用いる用語および記号の説明を行う。   Next, prior to describing the operation of the present invention, terms and symbols used in the following description will be described.

非特許文献1などに記載されているように、従来から知られている出力付き決定性有限オートマトンは、(Q, Σ, Δ, δ, λ, q0)の組によって与えられる。ただしQは状態集合である。Σは入力アルファベットであり、空文字εを含む。Δは出力アルファベット、δは遷移関数(Q×Σ→Q)、λは出力関数(Q→Δ)、q0は初期状態である。 As described in Non-Patent Document 1 and the like, a conventionally known deterministic finite automaton with output is given by a set of (Q, Σ, Δ, δ, λ, q 0 ). Where Q is a state set. Σ is an input alphabet and includes the empty character ε. Δ is an output alphabet, δ is a transition function (Q × Σ → Q), λ is an output function (Q → Δ), and q 0 is an initial state.

本発明のSDFAオートマトン8は(Qs, Σs, Δs, δs, λs, q0)の組によって与えられる。 The SDFA automaton 8 of the present invention is given by a set of (Q s , Σ s , Δ s , δ s , λ s , q 0 ).

ここで、Qsは状態集合25であり、従来の出力つき有限オートマトンの状態集合Qに相当するものである。 Here, Q s is the state set 25, which corresponds to the state set Q of the conventional finite automaton with output.

Δsは出力アルファベットであり、本実施例では条件番号16の集合の集合となる。 Δ s is an output alphabet, and is a set of sets of condition numbers 16 in this embodiment.

δsは状態遷移表格納部4によって実現される状態遷移関数であり、以下、現状態13がqs、入力文字14がσsのとき次状態15がqdとなることを、
δs(qs, σs) = qd
と表記する。
δ s is a state transition function realized by the state transition table storage unit 4. Hereinafter, when the current state 13 is q s and the input character 14 is σ s , the next state 15 is q d .
δ s (q s , σ s ) = q d
Is written.

q0は初期状態であり、その意味は従来から知られている出力つき決定性有限オートマトンと同じである。 q 0 is the initial state, the meaning is the same as the output with deterministic finite automaton conventionally known.

Σsは従来の出力付き有限オートマトンの入力アルファベットΣに任意文字σany, 除外文字σotherを加えた拡張入力アルファベットである。すなわち、
Σs=Σ∪{σany, σother }
とする。
Σ s is an extended input alphabet obtained by adding an arbitrary character σ any and an excluded character σ other to an input alphabet Σ of a conventional finite automaton with output. That is,
Σ s = Σ∪ {σ any , σ other }
And

また、
δs (qs, σs) = qd
であるとき、状態遷移11をtとすると、
t=trans(qs, qd, σs)
と表記するものとする。
Also,
δ s (q s , σ s ) = q d
When the state transition 11 is t,
t = trans (q s , q d , σ s )
It shall be written as

現状態13入力文字14の組に対して次状態15が存在する状態遷移11の集合を状態遷移集合26と呼び、Tと表記する。また、状態遷移t=trans(qs, qd, σs)に対して、qsを起点、qdを終点、σsを遷移文字と呼ぶ。更に、状態遷移tの起点を与える関数をSource、終点を与える関数をDestination、遷移文字を与える関数をCharと呼び、それぞれ
qs=Source(t)
qd=Destination(t)
σs=Char(t)
と表記する。
また、
λs(qs) = r
であるとき、出力記述18をdとすると
d=desc(qs, r)
と表記するものとする。
A set of state transitions 11 in which the next state 15 exists with respect to the set of the current state 13 input characters 14 is referred to as a state transition set 26 and is denoted as T. Also, for the state transition t = trans (q s , q d , σ s ), q s is called the starting point, q d is the end point, and σ s is called the transition character. Furthermore, the function that gives the starting point of state transition t is called Source, the function that gives the end point is called Destination, and the function that gives the transition character is called Char.
q s = Source (t)
q d = Destination (t)
σ s = Char (t)
Is written.
Also,
λ s (q s ) = r
If the output description 18 is d,
d = desc (q s , r)
It shall be written as

現状態13に対して出力アルファベットrが空でない出力記述12の集合を出力記述集合27と呼び、Dと表記する。出力記述d=desc(qs, r)に対して、qsを出力状態、rを出力結果と呼ぶ。更に、出力記述dの出力状態を与える関数をState、出力結果を与える関数をResultと呼び、それぞれ
qs =State(d)
r =Result(d)
と表記することにする。
A set of output descriptions 12 whose output alphabet r is not empty with respect to the current state 13 is called an output description set 27 and is denoted as D. For the output description d = desc (q s , r), q s is called the output state and r is called the output result. Furthermore, the function that gives the output state of the output description d is called State, and the function that gives the output result is called Result.
q s = State (d)
r = Result (d)
Will be written.

本発明のSDFAオートマトン8を生成する過程でNFAが生成されるが、NFAは(Q(NFA), Σs, Δs, δs(NFA), λs(NFA), q0(NFA))の組によって表される。 NFA is generated in the process of generating the SDFA automaton 8 of the present invention. NFA is (Q (NFA) , Σ s , Δ s , δ s (NFA) , λ s (NFA) , q 0 (NFA) ) Represented by a pair of

ここで、Q(NFA)はNFA状態集合22を表す。状態集合25はNFA状態の集合の集合となる。すなわち状態集合25をQと表記するときQ=2Q(NFA)の関係にある。以下、NFAの状態をDFAの状態と区別するため、q(NFA)と表記し、NFAの初期状態をq0(NFA)と表記する。 Here, Q (NFA) represents the NFA state set 22. The state set 25 is a set of NFA state sets. That is, when the state set 25 is expressed as Q, there is a relationship of Q = 2Q (NFA) . Hereinafter, in order to distinguish the NFA state from the DFA state, it is denoted as q (NFA), and the initial state of NFA is denoted as q 0 (NFA) .

δs(NFA)はNFAの状態遷移関数であり、現在のNFA状態13がq(NFA)、入力文字14がσsから次状態の集合への関数である。 δ s (NFA) is an NFA state transition function, where the current NFA state 13 is q (NFA) and the input character 14 is a function from σ s to the next state set.

λs(NFA)はNFAの出力関数であるり、現在のNFA状態13がq(NFA)のとき、出力アルファベットがr∈Δsとなることを
λs(NFA) (q(NFA)) = r
と表記する。
λ s (NFA) is an output function of NFA, or when the current NFA state 13 is q (NFA) , the output alphabet becomes r∈Δ s λ s (NFA) (q (NFA) ) = r
Is written.

Δsは条件番号16の集合、Σsは拡張入力アルファベットであり、その意味は本発明のSDFAオートマトン8と同じである。 Δ s is a set of condition numbers 16, Σ s is an extended input alphabet, and its meaning is the same as the SDFA automaton 8 of the present invention.

NFAの状態について、NFA状態遷移を以下のように定める。NFAの状態qd(NFA)
q d(NFA)∈δ(qs(NFA), σs)
のとき、NFA状態遷移32を
t(NFA)=trans(qs(NFA), qd(NFA), σs)
と表記するものとする。NFA状態遷移の集合をNFA状態遷移集合とよび、T(NFA)と表記する。また、同様に状態遷移t(NFA)=trans(qs(NFA), qd(NFA), σs)に対して、qs(NFA)を起点、qd(NFA)を終点、σsを遷移文字と呼ぶ。更に、状態遷移t(NFA)の起点を与える関数をSource、終点を与える関数をDestination、遷移文字を与える関数をCharと呼び、それぞれ
qs(NFA)=Source(t(NFA))
qd(NFA)=Destination(t(NFA))
σs(NFA)=Char(t(NFA))
と表記することにする。
The NFA state transition is defined as follows for the NFA state. NFA state q d (NFA) is
q d (NFA) ∈δ (q s (NFA) , σ s )
When NFA state transition 32 is
t (NFA) = trans (q s (NFA) , q d (NFA) , σ s )
It shall be written as A set of NFA state transitions is called an NFA state transition set and is denoted as T (NFA) . Similarly, for state transition t (NFA) = trans (q s (NFA) , q d (NFA) , σ s ), q s (NFA) is the starting point, q d (NFA) is the ending point, σ s Is called a transition character. Furthermore, the function that gives the start point of state transition t (NFA) is called Source, the function that gives the end point is called Destination, and the function that gives the transition character is called Char.
q s (NFA) = Source (t (NFA) )
q d (NFA) = Destination (t (NFA) )
σ s (NFA) = Char (t (NFA) )
Will be written.

NFA状態q(NFA)と出力アルファベットrの組をNFA出力記述と呼ぶことにする。
λs(q(NFA)) = r
であるとき、NFA出力記述34をd(NFA)とすると
d(NFA)=desc(qs(NFA), r)
と表記するものとする。
A set of the NFA state q (NFA) and the output alphabet r is called an NFA output description.
λ s (q (NFA) ) = r
If the NFA output description 34 is d (NFA)
d (NFA) = desc (q s (NFA), r)
It shall be written as

NFA状態13に対して出力アルファベットpが空でないNFA出力記述の集合をNFA出力記述集合24と呼び、D(NFA)と表記する。出力記述d(NFA)=desc(q(NFA), r)に対して、q(NFA)を出力状態、rを出力結果と呼ぶ。更に、出力記述dの出力状態を与える関数をState、出力結果を与える関数をResultと呼び、それぞれ
q(NFA) =State(d(NFA))
r(NFA) =Result(d(NFA))
と表記することにする。
A set of NFA output descriptions for which the output alphabet p is not empty for the NFA state 13 is called an NFA output description set 24 and is denoted as D (NFA) . For the output description d (NFA) = desc (q (NFA) , r), q (NFA) is called the output state and r is called the output result. Furthermore, the function that gives the output state of the output description d is called State, and the function that gives the output result is called Result.
q (NFA) = State (d (NFA) )
r (NFA) = Result (d (NFA) )
Will be written.

以上で用語および記号の説明を終わり、次に、動作について説明する。   This is the end of the explanation of terms and symbols. Next, the operation will be described.

図8に、本発明の文字列照合装置1の動作を示す。   FIG. 8 shows the operation of the character string matching device 1 of the present invention.

本発明の文字列照合装置1は、まず、照合条件2を受け取り状態遷移表生成部3により状態遷移11と出力記述12を生成する過程、すなわち、照合条件のコンパイルの手続きを実行する(ステップS51)。   First, the character string matching device 1 of the present invention receives the matching condition 2 and generates a state transition 11 and an output description 12 by the state transition table generating unit 3, that is, executes a procedure for compiling the matching condition (step S51). ).

次いで、入力文書6を受け取り、入力文字読み取り部7およびSDFAオートマトン8によって、状態遷移11と出力記述12を参照しながら照合結果10を出力する手続きを順次実行する(ステップS52)。   Next, a procedure for receiving the input document 6 and outputting the collation result 10 while referring to the state transition 11 and the output description 12 by the input character reading unit 7 and the SDFA automaton 8 is sequentially executed (step S52).

なお、本実施の例では1回の「照合条件のコンパイル」に対して「入力文書の照合」を1回行うこととしているが、1回の「照合条件のコンパイル」の手続きで生成された、状態遷移11と出力記述12を用いて、複数個の入力文書に対して「入力文書の照合」を行っても良い。   In this example, “comparison of input document” is performed once for “compilation of collation conditions”, but it is generated by a procedure of “compilation of collation conditions”. Using the state transition 11 and the output description 12, “input document matching” may be performed on a plurality of input documents.

次に、図9により、手続き「照合条件のコンパイル」について説明する。   Next, the procedure “Compilation of collation conditions” will be described with reference to FIG.

まず「ε遷移を含むNFAの生成」の手続きにより、正規表現から、ε遷移を含むNFAを生成する(ステップS101)。   First, an NFA including an ε transition is generated from a regular expression by a procedure of “Generation of NFA including an ε transition” (step S101).

次いで、「ε遷移の除去」の手続きによりNFAに含まれるε遷移(空文字による遷移)の除去を行う(ステップS102)。   Next, the ε transition (transition by an empty character) included in the NFA is removed by the procedure of “removing ε transition” (step S102).

次いで、「初期状態への遷移の追加」の手続きにより、照合に失敗した際の初期状態への遷移を追加する(ステップS103)。   Next, a transition to the initial state when the verification fails is added by the procedure “addition of transition to the initial state” (step S103).

次いで、「非決定的遷移の除去」の手続きにより、非決定的な遷移を除去する(ステップS104)。   Next, non-deterministic transitions are removed by the procedure of “removing non-deterministic transitions” (step S104).

次いで、「未使用状態の除去」の手続きにより、これまでの手順で不要になった状態の除去を行う(ステップS105)。   Next, the state unnecessary in the previous procedure is removed by the procedure of “removal of unused state” (step S105).

次いで、「状態数の削減」の手続きにより、冗長な状態および冗長な状態遷移の除去を行う(ステップS106)。   Next, the redundant state and redundant state transition are removed by the procedure “reduction of the number of states” (step S106).

次いで、「状態遷移表と出力表の生成」の手続きにより、状態集合から状態遷移表と出力表を生成する(ステップS107)。   Next, a state transition table and an output table are generated from the state set by a procedure of “generation of state transition table and output table” (step S107).

以上の手順により手続き「照合条件のコンパイル」を実行することができる。   The procedure “Compilation of collation conditions” can be executed by the above procedure.

ステップS101の、「ε遷移を含むNFAの生成」の手順については、非特許文献1などに示されている公知の手順を使用することができる。   For the procedure of “Generation of NFA including ε transition” in step S101, a known procedure shown in Non-Patent Document 1 or the like can be used.

ただし、図24に示すように正規表現中に含まれる任意の文字を表すメタキャラクタ「.」はσanyに置き換える。なお、以下、図24〜図31では状態q(NFA)を単にqと表記している。 However, as shown in FIG. 24, the metacharacter “.” Representing an arbitrary character included in the regular expression is replaced with σ any . Hereinafter, in FIG. 24 to FIG. 31, the state q (NFA) is simply expressed as q.

また、図25に示すように正規表現中に含まれる、特定文字集合以外を表すメタキャラクタ「^」はσotherに置き換え更に、該当する状態から初期状態q0(NFA)への状態遷移を追加するという手順を追加する。 In addition, as shown in FIG. 25, meta characters “^” that are included in the regular expression and represent a character set other than the specific character set are replaced with σ other , and a state transition from the corresponding state to the initial state q 0 (NFA) is added. Add a procedure to do.

ステップS102の、「ε遷移の除去」の手順についても、非特許文献1などに示されている公知の手順により、ε遷移(空文字による遷移)を遷移先集合への遷移で置き換えることにより、実現することができる。   The procedure of “removing the ε transition” in step S102 is also realized by replacing the ε transition (transition by an empty character) with a transition to the transition destination set by a known procedure shown in Non-Patent Document 1 or the like. can do.

次に、図10によってステップS103の「初期状態への失敗遷移の追加」の手続きを示す。   Next, FIG. 10 shows the procedure of “add failure transition to initial state” in step S103.

まず、ステップS102によって生成されたNFAの初期状態q0(NFA)からσanyによる遷移が存在しない場合はステップS202に進む。それ以外の場合は、ステップS203に進む(ステップS201)。 First, when there is no transition due to σ any from the initial state q 0 (NFA) of the NFA generated in step S102, the process proceeds to step S202. In cases other than that described here, process flow proceeds to Step S203 (Step S201).

「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)」の手続きを実行し、終了する(ステップS202)。 The procedure of “add failure transition to initial state (when there is no transition destination by σ any from the initial state)” is executed and the process ends (step S202).

ステップS201でNFAの初期状態q0(NFA)からσanyによる遷移が存在する場合は「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)」の手続きを実行し、終了する(ステップS203)。 If there is a transition due to σ any from the initial state q 0 (NFA) of NFA in step S201, the procedure “add failure transition to initial state (when there is a transition destination due to σ any from the initial state)” is executed. And the process ends (step S203).

なお、本実施例ではNFAの初期状態q0(NFA)からσanyによる遷移先が存在するか否かにより処理を分けているが、ステップS202の処理はステップS203によって代行することも可能である。ステップS202の処理はステップS203と比較すると適用可能な範囲が「初期状態からσanyによる遷移先が存在する」場合に限定されるが、より状態遷移の数を削減することができる。初期状態からσanyによる遷移先が存在するとは、照合条件となる正規表現の先頭に任意文字「.」が指定されるということであるが、実用上はこのような指定がされることは少ないため、多くの場合はステップS202の処理を適用することによって状態遷移の数を削減できる。 In the present embodiment, the process is divided from the initial state q 0 (NFA) of NFA depending on whether or not a transition destination by σ any exists, but the process of step S202 can be substituted by step S203. . The processing in step S202 is limited to the case where the applicable range is “the transition destination by σ any exists from the initial state” as compared with step S203, but the number of state transitions can be further reduced. The fact that there is a transition destination with σ any from the initial state means that an arbitrary character “.” Is specified at the beginning of the regular expression that serves as a matching condition, but such a specification is rarely used in practice. Therefore, in many cases, the number of state transitions can be reduced by applying the process of step S202.

以上の手順に従って、手続き「初期状態への失敗遷移の追加」を行うことができる。   According to the above procedure, the procedure “add failure transition to initial state” can be performed.

次に、ステップS202の「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)」の手続きについて説明する。 Next, the procedure of “addition of failed transition to initial state (when there is no transition destination by σ any from the initial state)” in step S202 will be described.

一般に、連続的な文字列照合を行うNFAまたはDFAでは、すべての状態から初期状態へのε遷移を追加することにより、任意の文字位置からの文字列照合を実現できる。図26に、正規表現(a|b|c(d|e))f に対応するNFAにε遷移を追加した例を示す。本発明のSDFAオートマトン8では、遷移に失敗した際に入力文字を進めずに初期状態q0に戻って再度状態遷移を行うため、初期状態q0へのε遷移を省略できる。すなわち、図27に示すNFAを構成すればよく、状態遷移の総数を大幅に削減することができる。しかし、初期状態q0(NFA)から遷移文字σにより状態q1(NFA)に遷移可能であるとき、状態q(NFA)からの遷移文字σによる遷移が存在するか、または、状態q(NFA)を起点とするいずれかの遷移文字σがσanyである場合は、σによる遷移が成功した場合にもσによりq1(NFA)にも遷移可能であるため、状態q(NFA)からσによる状態q1(NFA)への状態遷移を追加する。図28に、正規表現(a|b|c(d|e))f の場合の例を示す。図28の例では初期状態q0(NFA)から遷移文字aにより状態q1(NFA)に遷移可能であり、状態q3(NFA)から遷移文字aによる遷移が存在するため、図29のように遷移文字aによる状態q3(NFA)から状態q1(NFA)への遷移を追加する。状態q3(NFA)から遷移文字aによる遷移は非決定的な状態遷移となるが、後続の「非決定的遷移の除去」の手続きにより、この非決定的遷移は最終的に除去される。手続き「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)」および「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)」はこの処理を行うためのものである。 In general, in NFA or DFA that performs continuous character string matching, character string matching from any character position can be realized by adding an ε transition from all states to the initial state. FIG. 26 shows an example in which an ε transition is added to the NFA corresponding to the regular expression (a | b | c (d | e)) f. In SDFA automaton 8 of the present invention, in order to perform re-state transition back to the initial state q 0 without advancing an input character on failure to transition, it can be omitted ε transition to the initial state q 0. That is, the NFA shown in FIG. 27 may be configured, and the total number of state transitions can be greatly reduced. However, when it is possible to transition from the initial state q 0 (NFA) to the state q 1 (NFA) by the transition character σ, there is a transition from the state q (NFA) by the transition character σ, or the state q (NFA ) Is one of the transition characters σ starting from σ any, it is possible to transition to q 1 (NFA) by σ even when the transition by σ is successful, so from the state q (NFA) to σ Add a state transition to state q 1 (NFA) by. FIG. 28 shows an example of a regular expression (a | b | c (d | e)) f. In the example of FIG. 28, it is possible to transition from the initial state q 0 (NFA) to the state q 1 (NFA) by the transition character a, and there is a transition by the transition character a from the state q 3 (NFA) . Is added with a transition from state q 3 (NFA) to state q 1 (NFA) by transition character a. Although the transition from the state q 3 (NFA) by the transition character a becomes a non-deterministic state transition, this non-deterministic transition is finally removed by the subsequent procedure of “removing non-deterministic transition”. Procedures "Add failed transition to initial state (when there is no transition destination by σ any from the initial state)" and "Add failed transition to initial state (when there is a transition destination from the initial state by σ any )" Is for performing this processing.

図11により、ステップS202の「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)」の手続きについて説明する。 With reference to FIG. 11, the procedure of “addition of failed transition to initial state (when there is no transition destination by σ any from the initial state)” in step S202 will be described.

まず、t0(NFA) をステップS102によって生成されたNFAの初期状態q0(NFA)を起点とする最初の状態遷移とし、ステップS302に進む(ステップS301)。 First, t 0 (NFA) is set as the first state transition starting from the initial state q 0 (NFA) of the NFA generated in step S102, and the process proceeds to step S302 (step S301).

NFAの初期状態q0(NFA)を起点とするすべての状態遷移t0(NFA)の処理を終了したら手続きを終了する。それ以外の場合はステップS303に進む(ステップS302)。 When the processing of all the state transitions t 0 (NFA) starting from the initial state q 0 (NFA) of the NFA is completed, the procedure ends. In cases other than that described here, process flow proceeds to Step S303 (Step S302).

σをChar(t0(NFA))とし、ステップS304に進む(ステップS303)。 σ is set to Char (t 0 (NFA) ), and the process proceeds to step S304 (step S303).

q(NFA)をNFA状態集合Q(NFA)に含まれる最初のNFA状態とし、ステップS305に進む(ステップS304)。 Let q (NFA) be the first NFA state included in the NFA state set Q (NFA) , and go to step S305 (step S304).

NFA状態集合Q(NFA)に含まれるすべてのNFA状態q(NFA)の処理を終了したらステップS313に進む。それ以外の場合はステップS306に進む(ステップS305)。 When the processing of all the NFA states q (NFA) included in the NFA state set Q (NFA) is completed, the process proceeds to step S313. In cases other than that described here, process flow proceeds to Step S306 (Step S305).

NFA状態q(NFA)が初期状態q0(NFA)の場合は、ステップS312に進む。それ以外の場合はステップS307に進む(ステップS306)。 When the NFA state q (NFA) is the initial state q 0 (NFA) , the process proceeds to step S312. In cases other than that described here, process flow proceeds to Step S307 (Step S306).

t(NFA)を、q(NFA)を起点とする最初のNFA状態遷移とし、ステップS308に進む(ステップS307)。 Let t (NFA) be the first NFA state transition starting from q (NFA) , and proceed to step S308 (step S307).

q(NFA)を起点とするすべてのNFA状態遷移t(NFA)の処理を終了したらステップS312に進む。それ以外の場合はステップS309に進む(ステップS308)。 When the processing of all NFA state transitions t (NFA) starting from q (NFA) is completed, the process proceeds to step S312. In cases other than that described here, process flow proceeds to Step S309 (Step S308).

Char(t(NFA))=σ 、Char(t(NFA))= σanyのいずれかの条件が成立する場合はステップS310に進む。いずれの条件も成立しない場合はステップS311に進む(ステップS309)。 If either condition of Char (t (NFA) ) = σ and Char (t (NFA) ) = σ any is satisfied, the process proceeds to step S310. If neither condition is satisfied, the process proceeds to step S311 (step S309).

NFA状態遷移 trans(q(NFA), Destination(t0(NFA)), σ)がNFA状態遷移集合T(NFA)に含まれていなければTに加え、ステップS311に進む(ステップS310)。 If the NFA state transition trans (q (NFA) , Destination (t 0 (NFA) ), σ) is not included in the NFA state transition set T (NFA) , the process proceeds to step S311 (step S310).

t(NFA)をNFA状態q(NFA)を起点とする次のNFA状態遷移とし、ステップS305に進む(ステップS311)。 t (NFA) is set as the next NFA state transition starting from the NFA state q (NFA) , and the process proceeds to step S305 (step S311).

ステップS306にてNFA状態q(NFA)がNFAの初期状態q0(NFA)の場合、またはステップS308にてq(NFA)を起点とするすべてのNFA状態遷移t(NFA)を処理した場合はNFA状態q(NFA)をNFA状態集合QNFAに含まれる次のNFA状態とし、ステップS305に進む(ステップS312)。 If at step S306 NFA state q (NFA) is the initial state q 0 of NFA (NFA), or when treated with q all NFA state transitions t originating from the (NFA) (NFA) in step S308 The NFA state q (NFA) is set as the next NFA state included in the NFA state set Q NFA , and the process proceeds to step S305 (step S312).

ステップS305にてすべてのNFA状態q(NFA)の処理を終了した場合は、t0(NFA) をNFAの初期状態q0(NFA)を起点とする次のNFA状態遷移とし、ステップS302に進む(ステップS313)。 If all NFA states q (NFA) have been processed in step S305, t 0 (NFA) is set as the next NFA state transition starting from the initial state q 0 (NFA) of NFA, and the process proceeds to step S302. (Step S313).

以上の手順に従って、手続き「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在しない場合)」を行うことができる。 The procedure “Addition of failed transition to initial state (when there is no transition destination by σ any from the initial state)” can be performed according to the above procedure.

次に、ステップS203の「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)」の手続きについて説明する。この手続きの目的はステップS202と同じであるが、図30に示す正規表現(.|b|c(d|e))f のように、初期状態からσanyによる遷移先q1(NFA)が存在する場合は、すべての状態に対して、遷移が成功した場合にもq1(NFA)にも遷移可能となるため、図31に示すように、NFAの初期状態q0(NFA)を除くすべてのNFA状態q(NFA)とすべての遷移文字σに対して、q1(NFA)への遷移を追加する。 Next, the procedure of “add failure transition to initial state (when there is a transition destination by σ any from the initial state)” in step S203 will be described. The purpose of this procedure is the same as that of step S202, but the transition destination q 1 (NFA) by σ any from the initial state is changed as in the regular expression (. | B | c (d | e)) f shown in FIG. If it exists, since it is possible to transition to q 1 (NFA) even if the transition is successful for all states, the initial state q 0 (NFA) of NFA is excluded as shown in FIG. A transition to q 1 (NFA) is added to all NFA states q (NFA) and all transition characters σ.

図12により、ステップS203の「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)」の手続きについて説明する。 With reference to FIG. 12, the procedure of “add failure transition to initial state (when there is a transition destination by σ any from the initial state)” in step S203 will be described.

まず、t0(NFA) をステップS102によって生成されたNFAの初期状態q0(NFA)を起点とする最初のNFA状態遷移とし、ステップS352に進む(ステップS351)。 First, t 0 (NFA) is set as the first NFA state transition starting from the initial state q 0 (NFA) of NFA generated in step S102, and the process proceeds to step S352 (step S351).

NFAの初期状態q0(NFA)を起点とするすべてのNFA状態遷移t0(NFA)の処理を終了したら手続きを終了する。それ以外の場合はステップS353に進む(ステップS352)。 When the processing of all NFA state transitions t 0 (NFA) starting from the initial state q 0 (NFA) of the NFA is completed, the procedure is terminated. In cases other than that described here, process flow proceeds to Step S353 (Step S352).

σをChar(t0(NFA))とし、ステップS354に進む(ステップS353)。 σ is set to Char (t 0 (NFA) ), and the process proceeds to step S354 (step S353).

qをNFA状態集合Q(NFA)に含まれる最初のNFA状態とし、ステップS355に進む(ステップS354)。 Let q be the first NFA state included in the NFA state set Q (NFA) , and proceed to step S355 (step S354).

NFA状態集合Q(NFA)に含まれるすべてのNFA状態qの処理を終了したらステップS359に進む。それ以外の場合はステップS356に進む(ステップS355)。 When the processing of all NFA states q included in the NFA state set Q (NFA) is completed, the process proceeds to step S359. In cases other than that described here, process flow proceeds to Step S356 (Step S355).

NFA状態q(NFA)が初期状態q0(NFA)の場合は、ステップS356に進む。それ以外の場合はステップS357に進む(ステップS306)。 When the NFA state q (NFA) is the initial state q 0 (NFA) , the process proceeds to step S356. In cases other than that described here, process flow proceeds to Step S357 (Step S306).

NFA状態遷移trans (q(NFA), Destination(t0(NFA)), σ(NFA))がNFA状態遷移集合T(NFA)に含まれていなければT(NFA)に加え、ステップS355に進む(ステップS358)。 If NFA state transition trans (q (NFA) , Destination (t 0 (NFA) ), σ (NFA) ) is not included in NFA state transition set T (NFA) , in addition to T (NFA) , go to step S355 (Step S358).

ステップS355にてすべてのNFA状態q(NFA)の処理を終了した場合は、t0(NFA) をNFAの初期状態q0(NFA)を起点とする次のNFA状態遷移とし、ステップS352に進む(ステップS359)。 If all NFA states q (NFA) have been processed in step S355, t 0 (NFA) is set as the next NFA state transition starting from the initial state q 0 (NFA) of NFA, and the process proceeds to step S352. (Step S359).

以上の手順に従って、手続き「初期状態への失敗遷移の追加(初期状態からσanyによる遷移先が存在する場合)」を行うことができる。 The procedure “Addition of failed transition to initial state (when transition destination by σ any exists from initial state)” can be performed according to the above procedure.

次にステップS104の「非決定的遷移の除去」の手続きについて説明する。本手続きは、NFAに含まれる非決定的な遷移を除去し、決定的な遷移を生成するものである。図32に一例を示す。状態qsourceから遷移文字aによる状態遷移としてq1およびq2が存在する、すなわち非決定的であるため、遷移先の状態を併合する、すなわち図33に示すように遷移先のNFA状態集合q1およびq2の和集合qn =q1∪q2への状態遷移とする。この手順は基本的に非特許文献1などに示されているDFAの生成手順と同様であるが、本実施の例では、更に、図34のように、任意文字σanyによる状態遷移q2と遷移文字aによる状態遷移の終点q1を含む場合について、非決定的な遷移文字aに関する状態qn =q1∪q2への状態遷移の他に、除外文字σotherによる状態q1への遷移を生成する(図35)。 Next, the procedure of “remove non-deterministic transition” in step S104 will be described. This procedure removes non-deterministic transitions contained in NFA and generates deterministic transitions. An example is shown in FIG. Since q 1 and q 2 exist from the state q source as the state transition by the transition character a, that is, they are non-deterministic, the transition destination states are merged, that is, the transition destination NFA state set q 1 as shown in FIG. and the state transition to the union of q 2 q n = q 1 ∪q 2. This procedure is similar to the procedure of generating DFA which are basically shown in Non-Patent Document 1, in the example of the present embodiment, further, as shown in FIG. 34, the state transition q 2 by any character sigma any In the case of including the end point q 1 of the state transition by the transition character a, in addition to the state transition to the state q n = q 1 ∪q 2 for the non-deterministic transition character a, the transition to the state q 1 by the exclusion character σ other Is generated (FIG. 35).

図13によって、ステップS104の「非決定的遷移の除去」の手続きについて説明する。本手続きおよび「σotherに関する非決定的遷移の除去」の手続きでは変数Retryを使用する。変数RetryはTRUEまたはFALSEのいずれかの値をとることができる。 The procedure of “removing non-deterministic transition” in step S104 will be described with reference to FIG. The variable Retry is used in this procedure and the procedure of “removing non-deterministic transitions related to σ other ”. The variable Retry can take either TRUE or FALSE values.

まず「状態集合の初期化」の手続きを行い、ステップS402に進む(ステップS401)。   First, a “state set initialization” procedure is performed, and the process proceeds to step S402 (step S401).

次いで、変数RetryをFALSEに初期化し、ステップS401に進む(ステップS402)。   Next, the variable Retry is initialized to FALSE, and the process proceeds to step S401 (step S402).

次いで、「Σに関する非決定的遷移の除去」の手続きを行い。ステップS404に進む(ステップS403)。   Next, the procedure of “removing non-deterministic transitions regarding Σ” is performed. The process proceeds to step S404 (step S403).

次いで、「σotherに関する非決定的遷移の除去」の手続きを行い、ステップS405に進む(ステップS404)。 Next, the procedure of “removal of non-deterministic transition related to σ other ” is performed, and the process proceeds to step S405 (step S404).

変数RetryがTRUEの場合はステップS403に進む。FALSEの場合は終了する(ステップS405)。   If the variable Retry is TRUE, the process proceeds to step S403. If FALSE, the process ends (step S405).

以上の手順に従って、手続き「非決定的遷移の除去」を行うことができる。   According to the above procedure, the procedure “removing non-deterministic transition” can be performed.

次にステップS401の「状態集合の初期化」の手続きについて説明する。本手続きは、DFAの状態を生成するため、必要な状態集合を初期化するためのものであり、すべてのNFAの状態q(NFA)に対して、DFAの状態{q(NFA)}を関連する状態遷移ととともに生成することを目的とする。 Next, the procedure of “initialization of state set” in step S401 will be described. This procedure is for initializing the necessary set of states in order to generate DFA states. For all NFA states q (NFA) , DFA states {q (NFA) } are related. It is intended to generate with state transitions.

図14によって、ステップS401の「状態集合の初期化」の手続きについて説明する。   The procedure of “initialization of state set” in step S401 will be described with reference to FIG.

まず、状態集合Qを空に初期化しステップS502に進む(ステップS501)。   First, the state set Q is initialized to empty, and the process proceeds to step S502 (step S501).

次に、q(NFA)をNFA状態集合Q(NFA)に含まれる最初のNFA状態とし、ステップS502に進む(ステップS502)。 Next, q (NFA) is set as the first NFA state included in the NFA state set Q (NFA) , and the process proceeds to step S502 (step S502).

NFA状態集合Q(NFA)に含まれるすべてのNFA状態q(NFA)を処理した場合はステップS506に進む。それ以外の場合は、ステップS504に進む(ステップS503)。 If all the NFA states q (NFA) included in the NFA state set Q (NFA) have been processed, the process proceeds to step S506. In cases other than that described here, process flow proceeds to Step S504 (Step S503).

状態集合QにNFA状態集合(すなわちDFAの状態){q(NFA)}を加え、ステップS505に進む(ステップS504)。 The NFA state set (ie, DFA state) {q (NFA) } is added to the state set Q, and the process proceeds to step S505 (step S504).

q(NFA)をNFA状態集合Q(NFA)に含まれる次のNFA状態とし、ステップS503に進む(ステップS505)。 Let q (NFA) be the next NFA state included in the NFA state set Q (NFA) , and proceed to step S503 (step S505).

ステップS503においてNFA状態集合Q(NFA)に含まれるすべてのNFA状態(NFA)を処理した場合は、状態遷移集合Tを空にし、ステップS507に進む(ステップS506)。 When all the NFA states (NFA) included in the NFA state set Q (NFA) are processed in step S503, the state transition set T is emptied and the process proceeds to step S507 (step S506).

次に、t(NFA)をNFA状態遷移集合T(NFA)に含まれる最初のNFA状態遷移とし、ステップS508に進む(ステップS507)。 Next, t (NFA) is set as the first NFA state transition included in the NFA state transition set T (NFA) , and the process proceeds to step S508 (step S507).

NFA状態遷移集合T(NFA)に含まれるすべてのNFA状態遷移t(NFA)を処理したらステップS511に進む。それ以外の場合は、ステップS509に進む(ステップS508)。 When all the NFA state transitions t (NFA) included in the NFA state transition set T ( NFA) are processed, the process proceeds to step S511. In cases other than that described here, process flow proceeds to Step S509 (Step S508).

状態遷移集合Tにtrans({Source(t(NFA))}, {Destination(t(NFA))}, Char(t(NFA)))を加え、ステップS510に進む(ステップS509)。 Trans ({Source (t (NFA) )}, {Destination (t (NFA) )}, Char (t (NFA) )) is added to the state transition set T, and the process proceeds to step S510 (step S509).

t(NFA)をNFA状態遷移集合T(NFA)に含まれる次のNFA状態遷移とし、ステップS508に進む(ステップS510)。 Let t (NFA) be the next NFA state transition included in the NFA state transition set T (NFA) , and proceed to Step S508 (Step S510).

ステップS508においてT(NFA)に含まれるすべてのNFA状態遷移t(NFA)を処理した場合は、出力記述集合Dを空にし、ステップS512に進む(ステップS511)。 When all the NFA state transitions t (NFA) included in T (NFA) are processed in step S508, the output description set D is emptied and the process proceeds to step S512 (step S511).

次に、d(NFA)をNFA出力記述集合D(NFA)に含まれる最初のNFA出力記述とし、ステップS508に進む(ステップS512)。 Next, d (NFA) is set as the first NFA output description included in the NFA output description set D (NFA) , and the process proceeds to step S508 (step S512).

NFA出力記述集合D(NFA)に含まれるすべてのNFA出力記述d(NFA)を処理したら終了する。それ以外の場合は、ステップS509に進む(ステップS513)。 When all the NFA output descriptions d (NFA) included in the NFA output description set D ( NFA) have been processed, the process ends. In cases other than that described here, process flow proceeds to Step S509 (Step S513).

出力記述集合Dにdesc({State(d(NFA))}, Result(d(NFA)))を加え、ステップS510に進む(ステップS514)。 Add desc ({State (d (NFA) )}, Result (d (NFA) )) to the output description set D, and proceed to Step S510 (Step S514).

d(NFA)をNFA出力記述集合D(NFA)に含まれる次のNFA出力記述とし、ステップS508に進む(ステップS515)。 d (NFA) is set as the next NFA output description included in the NFA output description set D (NFA) , and the process proceeds to step S508 (step S515).

以上の手順によって、手続き「状態集合の初期化」を行うことができる。   The procedure “initialization of state set” can be performed by the above procedure.

次に、ステップS403の「Σに関する非決定的遷移の除去」の手続きについて説明する。本手続きでは、図32および図34に示した例のように、一つの遷移文字σ∈Σに対して複数の遷移先が存在するとき、新たな状態への遷移で置き換えることにより、各遷移文字σによる遷移先を一意に確定することを目的とする。   Next, the procedure of “removing non-deterministic transition regarding Σ” in step S403 will be described. In this procedure, as shown in FIG. 32 and FIG. 34, when there are a plurality of transition destinations for one transition character σ∈Σ, each transition character is replaced by a transition to a new state. The purpose is to uniquely determine the transition destination by σ.

図15によって、ステップS403の「Σに関する非決定的遷移の除去」の手続きについて説明する。本手続きでは変数Foundを使用する。変数RetryはTRUEまたはFALSEのいずれかの値をとることができる。   The procedure of “removal of non-deterministic transition regarding Σ” in step S403 will be described with reference to FIG. This procedure uses the variable Found. The variable Retry can take either TRUE or FALSE values.

まず、FoundをFALSEに初期化し、ステップS602に進む(ステップS601)。   First, Found is initialized to FALSE, and the process proceeds to step S602 (step S601).

次に、qを状態集合Q中の最初の状態遷移とし、ステップS603に進む(ステップS602)。   Next, q is set as the first state transition in the state set Q, and the process proceeds to step S603 (step S602).

状態集合Q中のすべての状態qを処理した場合はステップS616に進む。それ以外の場合はステップS604に進む(ステップS603)。   If all the states q in the state set Q have been processed, the process proceeds to step S616. In cases other than that described here, process flow proceeds to Step S604 (Step S603).

σを入力アルファベットΣ中の最初のアルファベットとし、ステップS605に進む(ステップS604)。   Let σ be the first alphabet in the input alphabet Σ, and go to step S605 (step S604).

入力アルファベットΣ中のすべてのアルファベットσを処理した場合はステップS610に進む。それ以外の場合はステップS606に進む(ステップS605)。   If all alphabets σ in the input alphabet Σ have been processed, the process proceeds to step S610. In cases other than that described here, process flow proceeds to Step S606 (Step S605).

qを起点とし、σを遷移文字とする状態遷移tが複数存在するか、またはσを遷移文字とする状態遷移tとσanyを遷移文字とする状態遷移tが存在する、すなわち、σによる遷移が非決定的である場合は、ステップS607に進む。それ以外の場合はステップS609に進む(ステップS606)。 There are multiple state transitions t starting with q and σ as a transition character, or there are state transitions t with σ as a transition character and state transition t with σ any as a transition character. If is non-deterministic, the process proceeds to step S607. In cases other than that described here, process flow proceeds to Step S609 (Step S606).

パラメータqsourceをq、σtをσに設定し手続き「新状態の生成」を行い、ステップS608に進む(ステップS607)。 The parameter “q source ” is set to “q” and σ t is set to “σ”, and the procedure “generation of new state” is performed, and the process proceeds to step S608 (step S607).

変数FoundにTRUEを設定し、ステップS609に進む(ステップS608)。   TRUE is set in the variable Found, and the process proceeds to step S609 (step S608).

σを入力アルファベットΣ中の次のアルファベットとし、ステップS605に進む(ステップS609)。   Let σ be the next alphabet in the input alphabet Σ, and proceed to step S605 (step S609).

ステップS605で入力アルファベットΣ中のすべてのアルファベットσを処理した場合は、tを状態qを起点とする最初の状態遷移とし、ステップS611に進む(ステップS610)。   When all the alphabets σ in the input alphabet Σ are processed in step S605, t is set as the first state transition starting from the state q, and the process proceeds to step S611 (step S610).

状態qを起点とするすべての状態遷移tを処理した場合はステップS615に進む。それ以外の場合はステップS612に進む(ステップS611)。   If all the state transitions t starting from the state q have been processed, the process proceeds to step S615. In cases other than that described here, process flow proceeds to Step S612 (Step S611).

tの遷移文字Char(t)がσanyの場合はステップS613に進む。それ以外の場合はステップS614に進む(ステップS612)。 If the transition character Char (t) of t is σ any , the process proceeds to step S613. In cases other than that described here, process flow proceeds to Step S614 (Step S612).

tの遷移文字をσotherで置き換える、すなわちtを (Source(t), Destination(t), σother)でおきかえ、ステップS614に進む(ステップS613)。 The transition character of t is replaced with σ other , that is, t is replaced with (Source (t), Destination (t), σ other ), and the process proceeds to step S614 (step S613).

tを状態qを起点とする次の状態遷移とし、ステップS611に進む(ステップS614)。   Let t be the next state transition starting from state q, and proceed to step S611 (step S614).

ステップS611で状態qを起点とするすべての状態遷移tを処理した場合はqを状態集合Q中の次の状態遷移とし、ステップS603に進む(ステップS615)。   When all the state transitions t starting from the state q are processed in step S611, q is set as the next state transition in the state set Q, and the process proceeds to step S603 (step S615).

ステップS603で状態集合Q中のすべての状態qを処理した場合は、変数FoundがTRUEであればステップS601に進む。それ以外の場合は終了する(ステップS616)。   When all the states q in the state set Q are processed in step S603, if the variable Found is TRUE, the process proceeds to step S601. Otherwise, the process ends (step S616).

以上の手順により、手続き「Σに関する非決定的遷移の除去」を行うことができる。   With the above procedure, the procedure “removal of non-deterministic transitions regarding Σ” can be performed.

次に、ステップS404の手続き「σotherに関する非決定的遷移の除去」について説明する。本手続きでは、図36に示すように、「Σに関する非決定的遷移の除去」によって生成された遷移文字σotherによる遷移について、状態qsourceから複数の状態q1およびq2への状態遷移が存在する場合、それらの和集合qn =q1∪q2の状態への遷移で置き換えることにより、図37に示すように、遷移文字σotherによる非決定的な遷移を除去する。 Next, the procedure “removal of non-deterministic transition related to σ other ” in step S404 will be described. In this procedure, as shown in FIG. 36, there is a state transition from the state q source to a plurality of states q 1 and q 2 for the transition by the transition character σ other generated by “removing the non-deterministic transition regarding Σ”. In this case, non-deterministic transitions due to the transition character σ other are removed as shown in FIG. 37 by replacing them with transitions to the state of the union q n = q 1 ∪q 2 .

図16により、ステップS404の手続き「σotherに関する非決定的遷移の除去」について説明する。本手続きでは変数Foundを使用する。変数FoundはTRUEまたはFALSEのいずれかの値をとることができる。また本手続きでは変数Counterを使用する。変数Counterは0以上の整数値を取ることができる。 The procedure “removal of non-deterministic transition related to σ other ” in step S404 will be described with reference to FIG. This procedure uses the variable Found. The variable Found can take either TRUE or FALSE values. In this procedure, the variable Counter is used. The variable Counter can take an integer value of 0 or greater.

まず、変数FoundにFALSEを設定し、ステップS702に進む(ステップS701)。   First, FALSE is set in the variable Found, and the process proceeds to step S702 (step S701).

qを状態集合Q中の最初の状態とし、ステップS703に進む(ステップS702)。   Let q be the first state in the state set Q, and go to step S703 (step S702).

状態集合Q中のすべての状態qを処理した場合はステップS714に進む。それ以外の場合はステップS701に進む(ステップS703)。   If all the states q in the state set Q have been processed, the process proceeds to step S714. In cases other than that described here, process flow proceeds to Step S701 (Step S703).

変数Counterに0を設定し、ステップS705に進む(ステップS704)。   The variable Counter is set to 0, and the process proceeds to step S705 (step S704).

tにqを起点とする最初の状態遷移を設定しステップS706に進む(ステップS705)。   The first state transition starting from q is set in t, and the process proceeds to step S706 (step S705).

qを起点とするすべての状態遷移tを処理した場合はステップS710に進む。それ以外の場合はステップS707に進む(ステップS706)。   If all the state transitions t starting from q have been processed, the process proceeds to step S710. In cases other than that described here, process flow proceeds to Step S707 (Step S706).

tの遷移文字Char(t)がσotherの場合はステップS708に進む。それ以外の場合はステップS709に進む(ステップS707)。 If the transition character Char (t) of t is σ other , the process proceeds to step S708. In cases other than that described here, process flow proceeds to Step S709 (Step S707).

変数Counterに1を加え、ステップS709に進む(ステップS708)。   1 is added to the variable Counter, and the process proceeds to step S709 (step S708).

tに、qを起点とする次の状態遷移を設定し、ステップS705に進む(ステップS709)。   The next state transition starting from q is set in t, and the process proceeds to step S705 (step S709).

ステップS706においてqを起点とするすべての状態遷移tを処理した場合は、変数Counterの値が2以上であればステップS711に進む。それ以外の場合はステップS713に進む(ステップS710)。   When all the state transitions t starting from q are processed in step S706, if the value of the variable Counter is 2 or more, the process proceeds to step S711. In cases other than that described here, process flow proceeds to Step S713 (Step S710).

パラメータqsourceをq、σtをσotherに設定し、手続き「新状態の生成」を呼び出し、ステップS712に進む(ステップS711)。 The parameter q source is set to q and σ t is set to σ other , the procedure “create new state” is called, and the process proceeds to step S712 (step S711).

変数FoundにTRUEを設定し、また変数RetryにTRUEを設定し、ステップS713に進む(ステップS712)。   TRUE is set in the variable Found, and TRUE is set in the variable Retry, and the process proceeds to step S713 (step S712).

qを状態集合Q中の次の状態遷移とし、ステップS703に進む(ステップS713)。   Let q be the next state transition in the state set Q, and go to step S703 (step S713).

ステップS703にて状態集合Q中のすべての状態qを処理した場合は、変数FoundがTRUEの場合はステップS701に進む。それ以外の場合は終了する(ステップS714)。   If all the states q in the state set Q have been processed in step S703, the process proceeds to step S701 if the variable Found is TRUE. Otherwise, the process ends (step S714).

以上の手順により、手続き「σotherに関する非決定的遷移の除去」を行うことができる。 By the above procedure, it is possible to perform the procedure "remove nondeterministic transition relates sigma other".

次に、ステップS607およびステップS711の手続き「新状態の生成」の手順について説明する。本手順は、状態qsourceから遷移文字σtに関する個々の非決定的な状態遷移を除去する手順である。 Next, the procedure “procedure of new state” in steps S607 and S711 will be described. This procedure is a procedure for removing individual non-deterministic state transitions related to the transition character σ t from the state q source .

図17によって、ステップS607およびステップS711の手続き「新状態の生成」の手順について説明する。手続き「新状態の生成」ではqsourceおよびσtをパラメータとする。 The procedure “procedure of new state” in steps S607 and S711 will be described with reference to FIG. The procedure “create new state” takes q source and σ t as parameters.

まず、状態qsourceを起点とし、σtにより遷移可能な状態の集合を求め、それらのNFA状態に関する和集合を求め、状態qnとする。qnが状態遷移集合Tに含まれている場合はステップS817に進む。それ以外の場合はステップS802に進む(ステップS801)。 First, a set of states that can be transitioned by σ t is obtained starting from the state q source , and a union related to these NFA states is obtained to obtain a state q n . If q n is included in the state transition set T, the process proceeds to step S817. In cases other than that described here, process flow proceeds to Step S802 (Step S801).

次に、状態qnを状態集合Qに追加し、ステップS803に進む(ステップS802)。 Next, the state q n is added to the state set Q, and the process proceeds to step S803 (step S802).

tをqsourceを起点とする最初の状態遷移とし、ステップS804に進む(ステップS803)。 The t as the first state transitions starting from the q source, the process proceeds to step S804 (step S803).

qsourceを起点とするすべての状態遷移tを処理した場合はステップS817に進む。それ以外の場合はステップS805に進む(ステップS804)。 If all the state transitions t starting from q source have been processed, the process proceeds to step S817. In cases other than that described here, process flow proceeds to Step S805 (Step S804).

Char(t)=σtの場合、またはChar(t)=σanyの場合はステップS806に進む。それ以外の場合はステップS816に進む(ステップS805)。 If Char (t) = σ t or Char (t) = σ any , the process proceeds to step S806. In cases other than that described here, process flow proceeds to Step S816 (Step S805).

t1を、Destination(t)を起点とする最初の状態遷移とし、ステップS807に進む(ステップS806)。 Let t 1 be the first state transition starting from Destination (t), and go to step S807 (step S806).

Destination(t)を起点とするすべての状態遷移t1を処理した場合はステップS812に進む。それ以外はステップS808に進む(ステップS807)。 If all the state transitions t 1 starting from Destination (t) have been processed, the process proceeds to step S812. Otherwise, the process proceeds to step S808 (step S807).

状態遷移trans(qn, Destination(t1), Char(t1))∈TでなければTにtrans(qn, Destination(t1), Char(t1))を追加し、ステップS809に進む(ステップS808)。 If state transition trans (q n , Destination (t 1 ), Char (t 1 )) ∈ T, add trans (q n , Destination (t 1 ), Char (t 1 )) to T and add to step S809 Proceed (step S808).

Char(t1)=σotherであればステップS810に進む。それ以外であればステップS811に進む(ステップS809)。 If Char (t 1 ) = σ other , the process proceeds to step S810. Otherwise, the process proceeds to step S811 (step S809).

手続き「σotherによる状態遷移の補正」を呼び出し、ステップS811に進む。このとき、パラメータとして(qsource, qn, t1)を与える(ステップS810)。 The procedure “correction of state transition by σ other ” is called, and the process proceeds to step S811. At this time, (q source , q n , t 1 ) is given as a parameter (step S810).

t1を、Destination(t)を起点とする次の状態遷移とし、ステップS807に進む(ステップS811)。 The t 1, the next state transition which starts the Destination (t), the process proceeds to step S807 (step S811).

ステップS807でDestination(t)を起点とするすべての状態遷移t1を処理した場合は、dをDestination(t)を出力状態とする最初の出力記述とし、ステップS813に進む(ステップS812)。 If all state transitions t 1 starting from Destination (t) are processed in step S807, d is set as the first output description in which Destination (t) is the output state, and the process proceeds to step S813 (step S812).

Destination(t)を出力状態とするすべての出力記述dを処理した場合はステップS816に進む。それ以外の場合は、ステップS814に進む(ステップS813)。   If all output descriptions d having Destination (t) as an output state have been processed, the process proceeds to step S816. In cases other than that described here, process flow proceeds to Step S814 (Step S813).

出力記述desc(qn,Result(d))∈DでなければDにdesc(qn,Result(d))を加え、ステップS815に進む(ステップS814)。 If the output description desc (q n , Result (d)) εD is not satisfied, desc (q n , Result (d)) is added to D, and the process proceeds to step S815 (step S814).

dをDestination(t)を出力状態とする次の出力記述とし、ステップS813に進む(ステップS815)。   d is set as the next output description in which Destination (t) is the output state, and the process proceeds to step S813 (step S815).

tをqsourceを起点とする次の状態遷移とし、ステップS804に進む(ステップS816)。 The t as the next state transitions starting from the q source, the process proceeds to step S804 (step S 816).

ステップS801でqnが状態遷移集合Tに含まれていない場合、およびステップS804でqsourceを起点とするすべての状態遷移tを処理した場合は、tをqsourceを起点とする最初の状態遷移とし、ステップS818に進む(ステップS817)。 If q n in step S801 is not included in the state transition set T, and the case of processing all the state transitions t which starts q source in step S804, the first state transition to a start point q source t Then, the process proceeds to step S818 (step S817).

qsourceを起点とするすべての状態遷移tを処理した場合はステップS822に進む。それ以外の場合はステップS819に進む(ステップS818)。 If all the state transitions t starting from q source have been processed, the process proceeds to step S822. In cases other than that described here, process flow proceeds to Step S819 (Step S818).

Char(t)=σtの場合はステップS820に進む。それ以外の場合はステップS821に進む(ステップS819)。 For Char (t) = σ t proceeds to step S820. In cases other than that described here, process flow proceeds to Step S821 (Step S819).

状態遷移tを状態遷移集合Tから削除し、ステップS821に進む(ステップS820)。   The state transition t is deleted from the state transition set T, and the process proceeds to step S821 (step S820).

tをqsourceを起点とする次の状態遷移とし、ステップS818に進む(ステップS821)。 The t as the next state transitions starting from the q source, the process proceeds to step S818 (step S821).

ステップS818でqsourceを起点とするすべての状態遷移tを処理した場合は、状態遷移trans(qsource, qn, σt) ∈TでなければTにtrans(qsource, qn, σt)を追加し、終了する(ステップS822)。 If all state transitions t starting from q source are processed in step S818, unless state transitions trans (q source , q n , σ t ) ∈T, trans (q source , q n , σ t ) Is added and the process ends (step S822).

以上の手順により、手続き「新状態の生成」を行うことができる。   With the above procedure, the procedure “generation of a new state” can be performed.

次にステップS811の手続き「σotherによる状態遷移の補正」について説明する。本手続きは、図38に示すように、非決定的遷移の除去の際に併合すべき状態q1, q2を起点とする状態遷移の中に遷移文字σotherによる状態遷移が含まれる場合の、状態q1, q2を起点とする状態遷移の終点となる状態の併合の手順を示すものである。図38の状態q1, q2を併合すると図39のようになり、状態qn =q1∪q2遷移文字bによる状態遷移の終点はq3∪q5となる。同様に、図40に示す状態q1, q2を併合すると、図41に示すように遷移文字b、c、σotherによる状態遷移の終点は、それぞれq3∪q6、q4∪q5、q4∪q6となる。 Next, the procedure “correction of state transition by σ other ” in step S811 will be described. As shown in FIG. 38, this procedure is performed when a state transition based on the transition character σ other is included in the state transitions starting from the states q 1 and q 2 to be merged when removing the non-deterministic transition. The procedure for merging states that are the end points of state transitions starting from states q 1 and q 2 is shown. When the states q 1 and q 2 in FIG. 38 are merged, the result is as shown in FIG. 39, and the end point of the state transition by the state q n = q 1 ∪q 2 transition character b is q 3 ∪q 5 . Similarly, when the states q 1 and q 2 shown in FIG. 40 are merged, as shown in FIG. 41, the end points of the state transitions by the transition characters b, c, and σ other are q 3 ∪q 6 and q 4 ∪q 5 , respectively. Q 4 ∪q 6 .

図18によって、ステップS811の手続き「σotherによる状態遷移の補正」について説明する。本手続きでは、拡張入力アルファベットσ∈Σsの集合、CharSetを用いる。 The procedure “correction of state transition by σ other ” in step S811 will be described with reference to FIG. In this procedure, a set of extended input alphabets σ∈Σ s , CharSet is used.

まずCharSetを空に初期化し、ステップS902に進む(ステップS901)。   First, CharSet is initialized to empty, and the process proceeds to step S902 (step S901).

次に、tをSource(tother)を起点とする最初の状態遷移とし、ステップS903に進む(ステップS902)。 Next, t is the first state transition starting from Source (t other ), and the process proceeds to step S903 (step S902).

Source(tother)を起点とするすべての状態遷移を処理した場合は、ステップS907に進む。それ以外の場合は、ステップS904に進む(ステップS903)。 If you are processing all the state transitions starting from the Source (t other), the process proceeds to step S907. In cases other than that described here, process flow proceeds to Step S904 (Step S903).

Char(t)が入力アルファベットΣに含まれる、すなわち、Char(t)≠σanyかつChar(t)≠σotherの場合はステップS906に進む。それ以外の場合はステップS905に進む(ステップS904)。 If Char (t) is included in the input alphabet Σ, ie, Char (t) ≠ σ any and Char (t) ≠ σ other , the process proceeds to step S906. In cases other than that described here, process flow proceeds to Step S905 (Step S904).

CharSetにChar(t)を加え、ステップS906に進む(ステップS905)。   Char (t) is added to CharSet, and the process proceeds to step S906 (step S905).

tをSource(tother)を起点とする次の状態遷移とし、ステップS903に進む(ステップS906)。 Let t be the next state transition starting from Source (t other ), and go to step S903 (step S906).

ステップS903でSource(tother)を起点とするすべての状態遷移を処理した場合は、t を状態qを起点とする最初の状態遷移とし、ステップS908に進む(ステップS907)。 If all state transitions starting from Source (t other ) are processed in step S903, t is the first state transition starting from state q, and the process proceeds to step S908 (step S907).

状態qを起点とするすべての状態遷移qを処理した場合は終了する。それ以外の場合はステップS909に進む(ステップS908)。   When all the state transitions q starting from the state q have been processed, the process ends. In cases other than that described here, process flow proceeds to Step S909 (Step S908).

Destination(t)≠Source(tother )の場合はステップS910に進む。それ以外の場合はステップS916に進む(ステップS909)。 If Destination (t) ≠ Source (t other ), the process proceeds to step S910. In cases other than that described here, process flow proceeds to Step S916 (Step S909).

t1 をDestination(t)を起点とする最初の状態遷移とし、ステップS911に進む(ステップS910)。 The t 1 as the first state transition which starts the Destination (t), the process proceeds to step S911 (step S910).

Destination(t)を起点とするすべての状態遷移t1 を処理した場合はステップS916に進む。それ以外の場合はステップS912に進む(ステップS911)。 If all the state transitions t 1 starting from Destination (t) have been processed, the process proceeds to step S916. In cases other than that described here, process flow proceeds to Step S912 (Step S911).

Char(t1)が入力アルファベットΣに含まれる、すなわち、Char(t1)≠σanyかつChar(t1)≠σotherの場合はステップS913に進む。それ以外の場合はステップS915に進む(ステップS912)。 If Char (t 1 ) is included in the input alphabet Σ, that is, Char (t 1 ) ≠ σ any and Char (t 1 ) ≠ σ other , the process proceeds to step S913. In cases other than that described here, process flow proceeds to Step S915 (Step S912).

Char(t1)がCharSetに含まれる場合はステップS915に進む。それ以外の場合はステップS914に進む(ステップS913)。 If Char (t 1 ) is included in CharSet, the process proceeds to step S915. In cases other than that described here, process flow proceeds to Step S914 (Step S913).

状態遷移trans(qn, Destination(tother), Char(t1))∈TでなければTにtrans(qn, Destination(tother), Char(t1))を加え、ステップS915に進む(ステップS914)。 If state transition trans (q n , Destination (t other ), Char (t 1 )) ∈T is not true, add trans (q n , Destination (t other ), Char (t 1 )) to T, and go to step S915 (Step S914).

t1 をDestination(t)を起点とする次の状態遷移とし、ステップS911に進む(ステップS915)。 The t 1 as the next state transition which starts the Destination (t), the process proceeds to step S911 (step S915).

ステップS909にてDestination(t)≠Source(tother )でなかった場合、あるいはステップS911にてDestination(t)を起点とするすべての状態遷移t1 を処理した場合は、t を状態qを起点とする次の状態遷移とし、ステップS908に進む(ステップS916)。 If not a Destination (t) ≠ Source (t other) at step S909, or if processing all the state transitions t 1 originating from the Destination (t) at step S911, starting from the state q the t And the process proceeds to step S908 (step S916).

以上の手順により、手続き「σotherによる状態遷移の補正」を行うことができる。 With the above procedure, the procedure “correction of state transition by σ other ” can be performed.

次に、ステップS105の「未使用状態の除去」の手続きについて説明する。本手続きでは、これまでの処理の結果発生した、状態遷移の終点とならない状態、すなわち、どのような入力に対しても決して到達しない状態を削除する。   Next, the procedure of “removing unused state” in step S105 will be described. In this procedure, a state that has occurred as a result of the processing so far and that does not become the end point of state transition, that is, a state that never reaches any input is deleted.

図19によって、ステップS105の「未使用状態の除去」の手続きについて説明する。本手続きでは変数Foundを用いる。変数FoundはTRUEまたはFALSEのいずれかの値をとることができる。   The procedure of “removing unused state” in step S105 will be described with reference to FIG. This procedure uses the variable Found. The variable Found can take either TRUE or FALSE values.

まず、変数FoundをFALSEにし、ステップS1002に進む(ステップS1001)。   First, the variable Found is set to FALSE, and the process proceeds to step S1002 (step S1001).

次に、qを状態集合Qに含まれる最初の状態とし、ステップS1003に進む(ステップS1002)。   Next, q is set as the first state included in the state set Q, and the process proceeds to step S1003 (step S1002).

状態集合Qに含まれるすべての状態qを処理した場合はステップS1017に進む。それ以外の場合はステップS1004に進む(ステップS1003)。   If all the states q included in the state set Q have been processed, the process proceeds to step S1017. In cases other than that described here, process flow proceeds to Step S1004 (Step S1003).

qが初期状態q0の場合はステップS1016に進む。それ以外の場合はステップS1005に進む(ステップS1004)。 If q is the initial state q 0 , the process proceeds to step S1016. In cases other than that described here, process flow proceeds to Step S1005 (Step S1004).

qを終点とする状態遷移が存在する場合はステップS1016に進む。それ以外の場合はステップS1006に進む(ステップS1005)。   If there is a state transition with q as the end point, the process proceeds to step S1016. In cases other than that described here, process flow proceeds to Step S1006 (Step S1005).

変数FoundをTRUEにし、ステップS1007に進む(ステップS1006)。   The variable Found is set to TRUE, and the process proceeds to step S1007 (step S1006).

tをqを起点とする最初の状態遷移とし、ステップS1008に進む(ステップS1007)。   t is the first state transition starting from q, and the process proceeds to step S1008 (step S1007).

qを起点とするすべての状態遷移tを処理した場合はステップS1011に進む。それ以外の場合はステップS1009に進む(ステップS1008)。   If all the state transitions t starting from q have been processed, the process proceeds to step S1011. In cases other than that described here, process flow proceeds to Step S1009 (Step S1008).

状態遷移tを状態遷移集合Tから取り除き、ステップS1010に進む(ステップS1009)。   The state transition t is removed from the state transition set T, and the process proceeds to step S1010 (step S1009).

tをqを起点とする次の状態遷移とし、ステップS1008に進む(ステップS1010)。   Let t be the next state transition starting from q, and go to step S1008 (step S1010).

ステップS1008でqを起点とするすべての状態遷移tを処理した場合は、dをqを出力状態とする最初の出力記述とし、ステップS1012に進む(ステップ1011)。   When all the state transitions t starting from q are processed in step S1008, d is set as the first output description in which q is the output state, and the process proceeds to step S1012 (step 1011).

qを出力状態とするすべての出力記述dを処理した場合はステップS1015に進む。それ以外の場合はステップ1013に進む(ステップ1012)。   If all output descriptions d having q as the output state have been processed, the process proceeds to step S1015. In cases other than that described here, process flow proceeds to Step 1013 (Step 1012).

出力記述dを出力記述集合Dから削除し、ステップS1014に進む(ステップS1013)。   The output description d is deleted from the output description set D, and the process proceeds to step S1014 (step S1013).

dをqを出力状態とする次の出力記述とし、ステップS1012に進む(ステップS1014)。   Let d be the next output description with q as the output state, and proceed to step S1012 (step S1014).

ステップS1012にてqを出力状態とするすべての出力記述dを処理した場合は、状態qを状態集合Qから削除し、ステップS1012に進む(ステップS1015)。   When all output descriptions d having q as the output state are processed in step S1012, the state q is deleted from the state set Q, and the process proceeds to step S1012 (step S1015).

qを状態集合Qに含まれる次の状態とし、ステップS1003に進む(ステップS1016)。   Let q be the next state included in the state set Q, and go to step S1003 (step S1016).

ステップ1003にて状態集合Qに含まれるすべての状態qを処理した場合は、変数Foundを調べFoundがTRUEの場合はステップS1002に進む。それ以外の場合は終了する(ステップ1017)。   If all the states q included in the state set Q are processed in step 1003, the variable Found is checked, and if Found is TRUE, the process proceeds to step S1002. Otherwise, the process ends (step 1017).

以上の手順により、手続き「未使用状態の除去」を行うことができる。   With the above procedure, the procedure “removal of unused state” can be performed.

なお、手続き「未使用状態の除去」は、状態遷移表を格納するのに必要なメモリ容量を削減することを目的としている。従って、本手続きを省略しても手続き「入力文書の照合」を実行することは可能であり、省略することにより、「照合条件のコンパイル」に要する時間を短縮することができる。   The procedure “removing unused state” is intended to reduce the memory capacity required to store the state transition table. Therefore, even if this procedure is omitted, the procedure “collation of input document” can be executed. By omitting this procedure, the time required for “compilation of collation conditions” can be shortened.

次に、図20によって、ステップS106の「冗長状態の除去」の手続きについて説明する。本手続きでは、2種類の不要な状態を除去する。第1の場合は、σotherによる状態遷移と同一の終点の状態を持つ状態遷移である。図42に一例を示す。図42において、遷移文字bによるq3を終点とする状態遷移を削除してもSDFAオートマトンの動作は同じであり、この状態遷移を削除することにより、状態遷移の総数を削減し、状態遷移表を格納するのに必要なメモリ容量を削減することができる。第2の場合は、すべての遷移文字に対する状態遷移の終点が等しい複数の状態の併合である。図43に一例を示す。図43において、状態q1と状態q2ではすべての遷移文字に対する状態遷移の終点が等しいため、状態q1と状態q2を併合したqn=q1∪q2で置換することができる。これらの2種類の場合の一方によって状態または状態遷移が削除されると、それにより他方による状態または状態遷移の削除が可能になる場合があるため、新たに状態または状態遷移が削除されなくなるまでこれら2種類を繰り返す。 Next, referring to FIG. 20, the “redundancy removal” procedure in step S106 will be described. In this procedure, two kinds of unnecessary states are removed. The first case is a state transition having the same end point state as the state transition by σ other . An example is shown in FIG. In FIG. 42, the operation of the SDFA automaton is the same even if the state transition whose end point is q 3 by the transition character b is deleted. By deleting this state transition, the total number of state transitions is reduced, and the state transition table It is possible to reduce the memory capacity required to store the data. The second case is a combination of a plurality of states with the same end point of the state transition for all the transition characters. An example is shown in FIG. In FIG. 43, since the end points of the state transitions for all the transition characters are the same in the state q 1 and the state q 2 , the state q 1 and the state q 2 can be replaced by q n = q 1 ∪q 2 . If a state or state transition is deleted by one of these two cases, it may be possible to delete the state or state transition by the other, so these will not be deleted until the state or state transition is no longer deleted. Repeat two types.

図20によって、ステップS106の「冗長状態の除去」の手続きについて説明する。本手続きでは変数StateRemovedおよびTransitionRemovedを用いる。変数StateRemovedおよびTransitionRemovedはTRUEまたはFALSEのいずれかの値をとることができる。   The procedure of “redundant state removal” in step S106 will be described with reference to FIG. This procedure uses the variables StateRemoved and TransitionRemoved. The variables StateRemoved and TransitionRemoved can take either TRUE or FALSE values.

まず、StateRemovedにTRUEを設定し、ステップS1102に進む(ステップS1101)。   First, TRUE is set in StateRemoved, and the process proceeds to step S1102 (step S1101).

手続き「冗長な状態遷移の削除」を呼び出し、ステップS1103に進む。本手続きの中でTransitionRemovedが設定される(ステップS1102)。   The procedure “delete redundant state transition” is called, and the process proceeds to step S1103. In this procedure, TransitionRemoved is set (step S1102).

TransitionRemoved=FALSEかつStateRemoved=FALSEの場合は終了する。それ以外の場合はステップS1104に進む(ステップS1103)   If TransitionRemoved = FALSE and StateRemoved = FALSE, the process ends. Otherwise, go to step S1104 (step S1103)

手続き「冗長な状態の併合」を呼び出し、ステップS1105に進む(ステップS1104)。   The procedure “merging redundant states” is called, and the process proceeds to step S1105 (step S1104).

TransitionRemoved=FALSEかつStateRemoved=FALSEの場合は終了する。それ以外の場合はステップS1102に進む(ステップS1105)。   If TransitionRemoved = FALSE and StateRemoved = FALSE, the process ends. In cases other than that described here, process flow proceeds to Step S1102 (Step S1105).

以上の手順により、手続き「冗長状態の除去」を行うことができる。   The procedure “removing the redundant state” can be performed by the above procedure.

なお、手続き「冗長状態の除去」は、状態遷移表を格納するのに必要なメモリ容量を削減することを目的としている。従って、本手続きを省略しても手続き「入力文書の照合」を実行することは可能であり、省略することにより、「照合条件のコンパイル」に要する時間を短縮することができる。   Note that the procedure “removing the redundant state” is intended to reduce the memory capacity necessary for storing the state transition table. Therefore, even if this procedure is omitted, the procedure “collation of input document” can be executed. By omitting this procedure, the time required for “compilation of collation conditions” can be shortened.

次に、ステップS1102の手続き「冗長な状態遷移の削除」について説明する。本手続きは、「冗長状態の除去」の第1の場合に相当し、図42に示すような、σotherによる状態遷移と同一の終点の状態を持つ状態遷移を削除する。 Next, the procedure “Deletion of redundant state transition” in step S1102 will be described. This procedure corresponds to the first case of “redundant state removal”, and deletes the state transition having the same end point state as the state transition by σ other as shown in FIG.

図21によって、ステップS1102の手続き「冗長な状態遷移の削除」について説明する。   The procedure “delete redundant state transition” in step S1102 will be described with reference to FIG.

まず、変数TransitionRemovedをFALSEに設定し、ステップS1202に進む(ステップS1201)。   First, the variable TransitionRemoved is set to FALSE, and the process proceeds to step S1202 (step S1201).

次に、tを状態遷移集合Tに含まれる最初の状態遷移とし、ステップS1203に進む(ステップS1202)。   Next, t is set as the first state transition included in the state transition set T, and the process proceeds to step S1203 (step S1202).

状態遷移集合Tに含まれるすべての状態tを処理した場合は終了する。それ以外の場合は、ステップS1204に進む(ステップS1203)。   When all the states t included in the state transition set T have been processed, the process ends. In cases other than that described here, process flow proceeds to Step S1204 (Step S1203).

Char(t)がσotherである場合にはステップS1205に進む。それ以外の場合はステップS1210に進む(ステップS1204)。 If Char (t) is σ other , the process proceeds to step S1205. In cases other than that described here, process flow proceeds to Step S1210 (Step S1204).

次に、t1をSource(t)を起点とする最初の状態遷移とし、ステップS1206に進む(ステップS1205)。 Next, the t 1 as the first state transitions starting from the Source (t), the process proceeds to step S1206 (step S1205).

Source(t)を起点とするすべての状態遷移t1を処理した場合はステップS1210に進む。それ以外の場合は、ステップS1207に進む(ステップS1206)。 If all the state transitions t 1 starting from Source (t) have been processed, the process proceeds to step S1210. In cases other than that described here, process flow proceeds to Step S1207 (Step S1206).

t1≠tかつDestination(t1)=Destination(t)の場合はステップS1208に進む。それ以外の場合はステップS1209に進む(ステップS1207)。 If t 1 ≠ t and Destination (t 1 ) = Destination (t), the process proceeds to step S1208. In cases other than that described here, process flow proceeds to Step S1209 (Step S1207).

状態遷移t1を状態遷移集合Tから削除し、ステップS1209に進む(ステップS1208)。 Remove the state transition t 1 from the state transition set T, the processing flow advances to step S1209 (step S1208).

t1をSource(t)を起点とする次の状態遷移とし、ステップS1206に進む(ステップS1209)。 The t 1 as the next state transition starting from the Source (t), the process proceeds to step S1206 (step S1209).

ステップS1204にてChar(t)がσotherでなかった場合、またはステップS1206にてSource(t)を起点とするすべての状態遷移t1を処理した場合は、tを状態遷移集合Tに含まれる次の状態遷移とし、ステップS1203に進む(ステップS1210)。 If Char (t) is not σ other in step S1204, or if all state transitions t 1 starting from Source (t) are processed in step S1206, t is included in the state transition set T. The next state transition is made, and the process proceeds to step S1203 (step S1210).

以上の手順により、手続き「冗長な状態遷移の削除」を行うことができる。   With the above procedure, the procedure “delete redundant state transition” can be performed.

次に、ステップ1104の手続き「冗長な状態の併合」について説明する。本手続きは、「冗長状態の除去」の第2の場合、すなわち、図43に示すような、すべての遷移文字に対する状態遷移の終点が等しい複数の状態を併合する。   Next, the procedure “merging redundant states” in step 1104 will be described. This procedure merges a plurality of states having the same end point of the state transition for all the transition characters as shown in FIG. 43 in the second case of “redundant state removal”.

ステップ1104の手続き「冗長な状態の併合」は、例えば、非特許文献1などに記載されている公知の手順により実行可能である。この手順によって、1つ以上の状態が併合されたときは変数StateRemovedをTRUEに設定する。それ以外の場合は変数StateRemovedをFALSEに設定する。   The procedure “merging redundant states” in step 1104 can be executed by a known procedure described in Non-Patent Document 1, for example. This procedure sets the variable StateRemoved to TRUE when one or more states are merged. Otherwise, set the variable StateRemoved to FALSE.

次に、図22によりステップS107の「状態遷移表と出力表の生成」について説明する。本手続きでは、状態集合25、状態遷移集合26、および出力記述集合27から、状態遷移11と出力記述12を取り出し、それぞれ状態遷移表格納部4、出力表格納部12に格納する。   Next, “generation of state transition table and output table” in step S107 will be described with reference to FIG. In this procedure, the state transition 11 and the output description 12 are extracted from the state set 25, the state transition set 26, and the output description set 27, and stored in the state transition table storage unit 4 and the output table storage unit 12, respectively.

まず、状態集合Qに含まれている状態の総数をNとするとき、各状態qに0〜N-1の一意の状態番号StateId(q)を対応づける(ステップS1301)。   First, when the total number of states included in the state set Q is N, a unique state number StateId (q) of 0 to N-1 is associated with each state q (step S1301).

状態遷移集合Tから最初の状態遷移tを取り出す(ステップS1302)。   The first state transition t is extracted from the state transition set T (step S1302).

状態遷移集合Tに含まれるすべての状態遷移tを処理したらステップS1307に進む。それ以外の場合はステップS1304に進む(ステップS1303)。   When all the state transitions t included in the state transition set T have been processed, the process proceeds to step S1307. In cases other than that described here, process flow proceeds to Step S1304 (Step S1303).

現状態Source(t)、入力文字Char(t)の組に対してハッシュ値計算部31でハッシュ値32を計算し、ステップS1305に進む(ステップS1304)。   The hash value calculation unit 31 calculates the hash value 32 for the set of the current state Source (t) and the input character Char (t), and the process proceeds to step S1305 (step S1304).

ハッシュ値32をオフセットとする状態遷移ハッシュポインタ33に現状態Source(t)、入力文字Char(t) 、次状態Destination(t)の組から成る状態遷移ハッシュチェイン34を追加し、ステップS1306に進む(ステップS1305)。   A state transition hash chain 34 composed of a combination of the current state Source (t), the input character Char (t), and the next state Destination (t) is added to the state transition hash pointer 33 using the hash value 32 as an offset, and the process proceeds to step S1306. (Step S1305).

tを状態遷移集合Tに含まれる次の状態遷移とし、ステップS1303に進む(ステップS1306)。   t is set as the next state transition included in the state transition set T, and the process proceeds to step S1303 (step S1306).

ステップS1303にて状態遷移集合Tに含まれるすべての状態遷移を処理した場合は、出力記述集合から最初の出力記述dを取り出す(ステップS1307)。   When all the state transitions included in the state transition set T are processed in step S1303, the first output description d is extracted from the output description set (step S1307).

出力記述集合Dに含まれるすべての出力記述dを処理したら終了する。それ以外の場合はステップS130に進む(ステップS1308)。   When all output descriptions d included in the output description set D have been processed, the process ends. In cases other than that described here, process flow proceeds to Step S130 (Step S1308).

State(d)の状態番号StateId(State(d))に対応する条件番号インデックス41に条件番号チェイン42としてResult(d)を追加しステップS1310に進む(ステップS1309)。   Result (d) is added as a condition number chain 42 to the condition number index 41 corresponding to the state number StateId (State (d)) of State (d), and the process proceeds to step S1310 (step S1309).

dを出力記述集合Dに含まれる次の出力記述とし、ステップS1308に進む(ステップS1310)。   Let d be the next output description included in the output description set D, and go to step S1308 (step S1310).

以上に示した手順により、手続き「状態遷移表と出力表の生成」を実行することができる。   The procedure “Generate state transition table and output table” can be executed by the procedure described above.

次いで、図23によって、手続き「入力文書の照合」について説明する。   Next, the procedure “collation of input document” will be described with reference to FIG.

まず、状態qに初期状態q0を設定し、ステップS2002に進む(ステップS2001)。 First, to set the initial state q 0 state q, the flow proceeds to step S2002 (step S2001).

出力表格納部5を探索し、qに関連する条件番号16を出力する。この手順は、条件番号インデックス41の現状態13の状態番号StateId(q)に対応する条件番号チェイン42へのポインタを順に探索することによって実現される。すべての条件番号チェイン42の探索が終わったらステップS2003に進む(ステップS2002)。   The output table storage unit 5 is searched, and the condition number 16 related to q is output. This procedure is realized by sequentially searching for a pointer to the condition number chain 42 corresponding to the state number StateId (q) of the current state 13 of the condition number index 41. When the search for all the condition number chains 42 is completed, the process proceeds to step S2003 (step S2002).

入力がすべて終了したら終了する。それ以外の場合はステップS2004に進む(ステップS2003)。   Exit when all input is complete. In cases other than that described here, process flow proceeds to Step S2004 (Step S2003).

入力文字読み取り部7から次の入力文字14を受け取り、σとし、ステップS2005に進む(ステップS2004)。   The next input character 14 is received from the input character reading unit 7 and set to σ, and the process proceeds to step S2005 (step S2004).

状態遷移表格納部4を探索し、状態qから遷移文字σによる遷移先qdが存在するか否か、すなわち、trans(q, qd, σ)∈Tなるqdが存在するかどうか調べ、ステップS2006に進む(ステップS2005)。 Searching a state transition table storing unit 4, whether a transition destination q d from the state q by the transition character sigma is present, i.e., checked trans (q, q d, sigma) whether ∈T becomes q d is present The process proceeds to step S2006 (step S2005).

遷移先qdが存在する場合はステップS2007に進む。それ以外の場合はステップS2008に進む(ステップS2006)。 When the transition destination q d exists, the process proceeds to step S2007. In cases other than that described here, process flow proceeds to Step S2008 (Step S2006).

qに qdを設定し、ステップS2002に進む(ステップS2007)。 Set q d to q, and proceed to step S2002 (step S2007).

ステップS2006でqdが存在しない場合は、状態qから遷移文字σotherによる遷移先qdが存在するか否か、すなわち、trans(q, qd, σother)∈Tなるqdが存在するかどうか調べ、ステップS2009に進む(ステップS2008)。 If q d is not present in step S2006 determines whether a transition destination q d by transition character sigma other from the state q exists, i.e., trans (q, q d, σ other) is ∈T becomes q d are present Check whether or not to proceed to step S2009 (step S2008).

遷移先qdが存在する場合はステップS2007に進む。それ以外の場合はステップS2010に進む(ステップS2009)。 When the transition destination q d exists, the process proceeds to step S2007. In cases other than that described here, process flow proceeds to Step S2010 (Step S2009).

状態qにq0を設定し、ステップS2006に進む。 Set q 0 to state q, and proceed to step S2006.

以上の手順により、手続き「入力文書の照合」を行うことができる。   With the above procedure, the procedure “verification of input document” can be performed.

以下、図44に示す照合条件2と図54に示す入力文字列の場合を例にとって、本実施の例の文字列照合装置の動作を説明する。図44の照合条件は特許文献3に示されていた図52の照合条件の表記を本実施の例の形式にあわせたものであり、図52と論理的に等価な照合条件である。   Hereinafter, the operation of the character string collating apparatus of the present embodiment will be described by taking the case of the collation condition 2 shown in FIG. 44 and the input character string shown in FIG. 54 as an example. The collation condition of FIG. 44 is a collation condition logically equivalent to FIG. 52, in which the collation condition notation of FIG. 52 shown in Patent Document 3 is matched with the format of this embodiment.

ステップS51に示した手続き「照合条件コンパイル」を実行することにより、図44の照合条件2から、図45に示す状態遷移表と、図46に示す出力表が生成される。なお、初期状態の状態番号を0とする。   By executing the procedure “Compilation condition compilation” shown in step S51, the state transition table shown in FIG. 45 and the output table shown in FIG. 46 are generated from the comparison condition 2 in FIG. Note that the initial state number is 0.

図45の状態遷移表は状態遷移表格納部4に格納される現状態13、入力文字14に対する次状態15を表で表現したものであり、例えば、現状態の状態番号が6で入力文字「d」の時、次状態は10となることを示している。図中で「−」は、次状態15が存在しないことを示しており、このような組み合わせに対しては状態遷移表格納部4はメモリを消費することなく格納することができる。従来の出力つき有限状態オートマトンでは図53に示す通り、90個の組み合わせを必要とするのに対し、図45の例では、46個の状態遷移につき情報を格納すればよく、状態遷移表を格納するのに必要なメモリを削減するという効果が得られている。   The state transition table of FIG. 45 is a table representing the current state 13 and the next state 15 for the input character 14 stored in the state transition table storage unit 4. For example, the state number of the current state is 6 and the input character “ "d" indicates that the next state is 10. In the drawing, “-” indicates that the next state 15 does not exist, and the state transition table storage unit 4 can store such a combination without consuming memory. In the conventional finite state automaton with output, as shown in FIG. 53, 90 combinations are required, whereas in the example of FIG. 45, information may be stored for 46 state transitions, and a state transition table is stored. This has the effect of reducing the memory required to do this.

図46の出力表は出力表格納部5に格納される現状態13に対応する条件番号16の集合を表で表現したものであり、例えば、現状態が4のとき、条件番号0を出力することを示している。   The output table of FIG. 46 is a table representing a set of condition numbers 16 corresponding to the current state 13 stored in the output table storage unit 5. For example, when the current state is 4, condition number 0 is output. It is shown that.

一例として入力文字列「aaca」を入力とした場合の動作を図47に示す。まず、状態qを初期状態(状態0)に設定する。次いで1文字目の文字「a」を読み、状態0における文字「a」の遷移先である状態2に遷移する。文字「a」による遷移先が定義されているのでσotherの参照は不要であり、このことを図47中では(不要)と表記している。次に、2文字目の文字「a」を読み、状態2における文字「a」の遷移先である状態5に遷移する。次に、3文字目の文字「c」を読み、状態5における文字「c」の遷移先である状態9に遷移する。次に、4文字目の文字「a」を読み、状態9における文字「a」の遷移先である状態12に遷移する。ここで入力が終了する。 As an example, FIG. 47 shows an operation when the input character string “aaca” is input. First, the state q is set to the initial state (state 0). Next, the first character “a” is read, and a transition is made to state 2 which is the transition destination of character “a” in state 0. Since the transition destination by the character “a” is defined, it is not necessary to refer to σ other , and this is expressed as (unnecessary) in FIG. Next, the second character “a” is read, and the state transitions to state 5 which is the transition destination of character “a” in state 2. Next, the third character “c” is read, and a transition is made to state 9, which is the transition destination of character “c” in state 5. Next, the character “a” of the fourth character is read, and the state transitions to the state 12 that is the transition destination of the character “a” in the state 9. The input ends here.

特許文献3に記載された従来の技術では同等の条件に対して7回の状態遷移表の参照を必要としていたが、本実施の例では4回で済む。このように、本発明によれば、遷移の失敗による状態遷移表の参照回数を1文字当り2回以下とし、遷移の失敗が繰り返されることによる性能低下による性能低下を防止し、高速な文字列照合を可能にすることを目的とする。   In the conventional technique described in Patent Document 3, it is necessary to refer to the state transition table seven times for the same condition. However, in the present embodiment, only four times are required. As described above, according to the present invention, the number of times of reference to the state transition table due to transition failure is set to 2 or less per character, performance degradation due to performance degradation due to repeated transition failure is prevented, and a high-speed character string The purpose is to enable verification.

なお、図44の照合条件は、特許文献3に記載の技術との比較のために記載したものであるが、初期状態からすべての文字による遷移が可能であると言う特殊な条件を持っている。図44の照合条件の目的とするところは照合対象文字列「abcd」のうち一文字が変化してもその文字列を検出できるようにすることであるが、その目的および照合条件の意味をほとんど変更せずに図48の照合条件に変換することができる。このような場合には、状態遷移に必要なメモリを更に削減し、本実施の例の効果をより発揮することができる。   The collation conditions in FIG. 44 are described for comparison with the technique described in Patent Document 3, but have a special condition that all characters can be transitioned from the initial state. . The purpose of the collation condition in FIG. 44 is to make it possible to detect the character string even if one character of the collation target character string “abcd” changes, but the purpose and the meaning of the collation condition are almost changed. Without being converted to the collation conditions shown in FIG. In such a case, the memory required for the state transition can be further reduced, and the effects of the present embodiment can be further exhibited.

ステップS51に示した手続き「照合条件コンパイル」を実行することにより、図48の照合条件2から、図49に示す状態遷移表と、図50に示す出力表が生成される。なお、初期状態の状態番号を0とする。   By executing the procedure “Compilation Condition Compilation” shown in Step S51, the state transition table shown in FIG. 49 and the output table shown in FIG. 50 are generated from the collation condition 2 in FIG. Note that the initial state number is 0.

図49の状態遷移表の意味は図45と同様であり、状態遷移表格納部4に格納が必要な状態遷移の数は23個に削減され、更に必要なメモリを削減するという効果が得られている。   The meaning of the state transition table of FIG. 49 is the same as that of FIG. 45, and the number of state transitions that need to be stored in the state transition table storage unit 4 is reduced to 23, and the effect of further reducing the necessary memory is obtained. ing.

また、図48の照合条件2について、入力「xabxd」に対する動作を図51に示す。状態0において1文字目の「x」の遷移先は定義されていないので、σotherを参照するが、それでも遷移先が定義されていないので次状態は初期状態、すなわち状態0とする。このとき状態遷移表の参照は2回行われる。以下、2文字目の「a」で状態3、3文字目の「b」で状態6に遷移する。4文字目の「x」では、「x」の遷移先は定義されていないので、σotherを参照し、次状態1を得る。このとき状態遷移表の参照は2回である。更に、5文字目の「d」で状態2に遷移する。状態2は出力となる条件番号16として番号0が存在しているので、これを出力する。この場合、状態遷移表の参照回数は7回となる。 FIG. 51 shows the operation for the input “xabxd” with respect to the matching condition 2 in FIG. Since the transition destination of the first character “x” is not defined in state 0, σ other is referred to. However, since the transition destination is still not defined, the next state is the initial state, that is, state 0. At this time, the state transition table is referred to twice. Subsequently, the state transitions to state 3 with the second character “a” and to state 6 with the third character “b”. In the fourth character “x”, since the transition destination of “x” is not defined, σ other is referred to and the next state 1 is obtained. At this time, the state transition table is referenced twice. Further, the state transits to the state 2 at the fifth character “d”. In the state 2, since the number 0 exists as the condition number 16 to be output, this is output. In this case, the reference count of the state transition table is 7 times.

なお、非特許文献1など記述されているように、出力を持たない一般のDFAは、出力アルファベットとして「受理した」「受理しない」という2種類の情報を出力する特殊なMoore機械とみなすことができる。本実施の例でも、単に照合結果に条件番号が存在するか否かを判定することにより、「受理した」「受理しない」という2種類の情報を出力する文字列照合装置を構成できる。   Note that, as described in Non-Patent Document 1, etc., a general DFA that does not have an output can be regarded as a special Moore machine that outputs two types of information, “accepted” and “not accepted” as output alphabets. it can. Also in this example, it is possible to configure a character string collating apparatus that outputs two types of information “accepted” and “not accepted” by simply determining whether or not a condition number exists in the collation result.

なお、以上の実施の例では、入力および照合の対象は「文字」であるとしてきたが、「文字」は人間に可読な文字列に限定されず、任意の記号列、データ列に対して適用が可能である。例えば遺伝子配列やセンサなどにより計測されたデータの識別に適用しても良い。   In the above embodiment, the target of input and verification is “character”. However, “character” is not limited to a human-readable character string, and can be applied to any symbol string or data string. Is possible. For example, the present invention may be applied to identification of data measured by a gene sequence or a sensor.

なお、以上の実施の例では、状態遷移表格納部4に状態遷移ハッシュ表35を使用するものとしたが、配列、木構造、など2次元構造の表を論理的に表現可能ないかなるデータ構造によって実現しても良い。   In the above embodiment, the state transition table storage unit 4 uses the state transition hash table 35. However, any data structure capable of logically expressing a two-dimensional table such as an array or a tree structure. It may be realized by.

また、初期状態など使用頻度の高い状態に対してはアクセス速度の高速な配列などのデータ構造を使用し、使用頻度の低い状態に対してはメモリ容量の効率の高いハッシュ表や木構造などのデータ構造を併用しても良い。   In addition, data structures such as arrays with high access speed are used for frequently used states such as the initial state, and hash tables and tree structures with high memory capacity are used for infrequently used states. Data structures may be used together.

なお、以上の実施の例では、出力表格納部5に条件番号インデックス41を使用するものとしたが、木構造やハッシュ表など、1次元構造の表を論理的に表現可能ないかなるデータ構造によって実現してもよい。   In the above embodiment, the condition number index 41 is used for the output table storage unit 5. However, any data structure that can logically express a one-dimensional table such as a tree structure or a hash table is used. It may be realized.

この発明は、文字列照合装置に適用することが可能である。   The present invention can be applied to a character string matching device.

Claims (17)

正規表現で記述された照合条件に基づいて状態遷移表を生成する状態遷移表生成部と、
前記状態遷移表生成部により生成された状態遷移表に基づいて遷移するオートマトンとを備えるとともに、
前記状態遷移表生成部は、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、所定の状態へ遷移する除外文字を設定して状態遷移表を作成することを特徴とする文字列照合装置。
A state transition table generating unit that generates a state transition table based on a matching condition described in a regular expression;
With an automaton that transitions based on the state transition table generated by the state transition table generation unit,
The state transition table generation unit sets an excluded character that transitions to a predetermined state when there is no next transition destination state for the set of the current state and the input character in the state transition table generated based on the matching condition A character string collating apparatus characterized by creating a state transition table.
前記状態遷移表生成部は、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、初期状態へ遷移する状態遷移表を作成することを特徴とする請求項1記載の文字列照合装置。   The state transition table generation unit creates a state transition table that transitions to an initial state when there is no next transition destination state for the pair of the current state and the input character in the state transition table generated based on the matching condition The character string collating apparatus according to claim 1, wherein: 前記状態遷移表生成部は、複数の照合条件が入力された場合、状態の併合に基づいて出力記述の併合を行い、出力表作成し、
前記オートマトンは、前記出力表に基づいて出力することを特徴とする請求項1記載の文字列照合装置。
When a plurality of collation conditions are input, the state transition table generation unit performs output description merging based on state merging, creates an output table,
The character string collating apparatus according to claim 1, wherein the automaton is output based on the output table.
前記状態遷移表生成部は、ある状態から任意文字による遷移先q1と所定の遷移文字σによる遷移先q2が存在するとき、前記任意文字を前記除外文字で置き換え、前記所定の遷移文字σによる遷移先をq1とq2を併合した状態で置き換えることを特徴とする請求項1記載の文字列照合装置。 The state transition table generation unit replaces the arbitrary character with the exclusion character when the transition destination q 1 by an arbitrary character and the transition destination q 2 by a predetermined transition character σ exist from a certain state, and the predetermined transition character σ 2. The character string matching apparatus according to claim 1 , wherein the transition destination is replaced with a state where q1 and q2 are merged. 前記状態遷移表生成部は、ある状態から前記除外文字による遷移先の状態が複数存在するとき、それら複数の状態を併合した状態で置き換えることを特徴とする請求項1記載の文字列照合装置。   The character string matching device according to claim 1, wherein the state transition table generation unit replaces a plurality of states with a merged state when there are a plurality of transition destination states by the excluded character from a certain state. 前記状態遷移表生成部は、所定の状態q1,q2を併合する際に、q2から前記除外文字によりq3に状態遷移する場合、q1を起点とする状態遷移先とq3を併合することを特徴とする請求項1記載の文字列照合装置。 When the state transition table generation unit merges the predetermined states q 1 and q 2 , and changes state from q 2 to q 3 by the exclusion character, the state transition destination and q 3 starting from q 1 The character string collating device according to claim 1, wherein the character string collating devices are merged. 前記状態遷移表生成部は、NFAを生成する際に、「.」による遷移を任意文字遷移とする状態遷移を生成することを特徴とする請求項1記載の文字列照合装置。   The character string matching device according to claim 1, wherein the state transition table generating unit generates a state transition in which a transition by “.” Is an arbitrary character transition when generating the NFA. 前記状態遷移表生成部は、NFAを生成する際に、[^a]による遷移を、文字aによる遷移と除外文字σotherによる遷移とに置き換えることを特徴とする請求項1記載の文字列照合装置。 2. The character string matching according to claim 1, wherein the state transition table generation unit replaces the transition by [^ a] with the transition by the character a and the transition by the excluded character σ other when generating the NFA. apparatus. 前記状態遷移表生成部は、通常の文字と除外文字σotherが同一の状態に遷移するときに、通常の文字による状態遷移を削除することを特徴とする請求項1記載の文字列照合装置。 The character string matching device according to claim 1, wherein the state transition table generation unit deletes a state transition caused by a normal character when the normal character and the excluded character σ other transition to the same state. 通常の文字と除外文字σotherとが同一の状態に遷移するときに、通常の文字による状態遷移を削除した後に、すべての文字に対して同一の状態に遷移する複数の状態を併合し、さらに、すべての文字に対して同一の状態に遷移する複数の状態を併合した後に、通常の文字と除外文字σotherとが同一の状態に遷移するときに、通常の文字による状態遷移を削除することを特徴とする請求項9記載の文字列照合装置。 When the normal character and the excluded character σ other transition to the same state, after deleting the state transition by the normal character, merge multiple states that transition to the same state for all characters, and , After merging multiple states that transition to the same state for all characters, when the normal character and the excluded character σ other transition to the same state, delete the state transition by the normal character The character string matching device according to claim 9. 前記状態遷移表生成部は、前記状態遷移表をハッシュ表により構成することを特徴とする請求項1記載の文字列照合装置。   The character string matching device according to claim 1, wherein the state transition table generation unit configures the state transition table with a hash table. 前記オートマトンは、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、入力文字を読み進めずに初期状態へ遷移することを特徴とする請求項1記載の文字列照合装置。   In the state transition table generated based on the matching condition, the automaton transitions to the initial state without reading the input character when there is no next transition destination state for the set of the current state and the input character. The character string matching device according to claim 1, wherein 前記状態遷移表生成部は、複数の照合条件が入力された場合、状態の併合に基づいて出力記述の併合を行い、出力表作成し、
前記オートマトンは、前記出力表に基づいて出力することを特徴とする請求項12記載の文字列照合装置。
When a plurality of collation conditions are input, the state transition table generation unit performs output description merging based on state merging, creates an output table,
13. The character string matching apparatus according to claim 12, wherein the automaton is output based on the output table.
前記状態遷移表生成部は、状態遷移表を生成する際、初期状態q0から所定の遷移文字σにより所定の状態q1に遷移可能であり、かつ、任意の状態qから前記所定の遷移文字σにより遷移可能であるとき、前記任意の状態qから前記所定の遷移文字σによる前記所定の状態q1への状態遷移を追加することを特徴とする請求項12に記載の文字列照合装置。 When generating the state transition table, the state transition table generating unit is capable of transitioning from the initial state q 0 to the predetermined state q 1 with a predetermined transition character σ, and from the arbitrary state q to the predetermined transition character 13. The character string matching apparatus according to claim 12, wherein when the transition is possible by σ, a state transition from the arbitrary state q to the predetermined state q 1 by the predetermined transition character σ is added. 前記状態遷移表生成部は、前記状態遷移表をハッシュ表により構成することを特徴とする請求項12記載の文字列照合装置。   The character string matching device according to claim 12, wherein the state transition table generation unit configures the state transition table by a hash table. コンピュータを制御して、文字列の照合を行うプログラムであって、
状態遷移表生成部により、正規表現で記述された照合条件に基づいて状態遷移表を生成するとともに、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、所定の状態へ遷移する除外文字を設定して状態遷移表を作成する処理と、
前記状態遷移表生成部により生成された状態遷移表に基づいて遷移する処理とを前記コンピュータに実行させることを特徴とする文字列照合プログラム。
A program for controlling a computer and checking character strings,
The state transition table generation unit generates a state transition table based on the matching condition described by the regular expression, and in the state transition table generated based on the matching condition, the next state for the set of the current state and the input character When there is no transition destination state, a process for creating a state transition table by setting an exclusion character to transition to a predetermined state;
A character string matching program that causes the computer to execute a process of making a transition based on a state transition table generated by the state transition table generating unit.
前記状態遷移表生成部により生成された状態遷移表に基づいて遷移するとともに、前記照合条件に基づいて生成された状態遷移表において、現状態と入力文字の組に対する次の遷移先状態が存在しない場合、入力文字を読み進めずに初期状態へ遷移する処理とを前記コンピュータに実行させることを特徴とする請求項16記載の文字列照合プログラム。   Transition is performed based on the state transition table generated by the state transition table generation unit, and in the state transition table generated based on the collation condition, there is no next transition destination state for the set of the current state and the input character The character string matching program according to claim 16, further comprising: causing the computer to execute a process of transitioning to an initial state without reading an input character.
JP2010071824A 2010-03-26 2010-03-26 Character string collation device and character string collation program Active JP5077380B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010071824A JP5077380B2 (en) 2010-03-26 2010-03-26 Character string collation device and character string collation program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010071824A JP5077380B2 (en) 2010-03-26 2010-03-26 Character string collation device and character string collation program

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2007531511A Division JP4535130B2 (en) 2004-12-09 2004-12-09 Character string collation device and character string collation program

Publications (2)

Publication Number Publication Date
JP2010225156A true JP2010225156A (en) 2010-10-07
JP5077380B2 JP5077380B2 (en) 2012-11-21

Family

ID=43042222

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010071824A Active JP5077380B2 (en) 2010-03-26 2010-03-26 Character string collation device and character string collation program

Country Status (1)

Country Link
JP (1) JP5077380B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012238217A (en) * 2011-05-12 2012-12-06 Fujitsu Ltd Matching device and matching program
JP2013065188A (en) * 2011-09-16 2013-04-11 Toshiba Corp Automaton determining method, automaton determining device and automaton determining program
JP2013101565A (en) * 2011-11-09 2013-05-23 Fujitsu Ltd Automaton processing apparatus, automaton processing method and automaton processing program

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63311530A (en) * 1987-06-15 1988-12-20 Hitachi Ltd Method and device for retrieving character string
JPH10105576A (en) * 1996-06-27 1998-04-24 Fujitsu Ltd Device and method for collating plural symbol strings based on sparse state transition table
JPH10207912A (en) * 1996-11-21 1998-08-07 Sharp Corp Method for retrieving character and character string and recording medium to be used for the same

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63311530A (en) * 1987-06-15 1988-12-20 Hitachi Ltd Method and device for retrieving character string
JPH10105576A (en) * 1996-06-27 1998-04-24 Fujitsu Ltd Device and method for collating plural symbol strings based on sparse state transition table
JPH10207912A (en) * 1996-11-21 1998-08-07 Sharp Corp Method for retrieving character and character string and recording medium to be used for the same

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012238217A (en) * 2011-05-12 2012-12-06 Fujitsu Ltd Matching device and matching program
JP2013065188A (en) * 2011-09-16 2013-04-11 Toshiba Corp Automaton determining method, automaton determining device and automaton determining program
US8943006B2 (en) 2011-09-16 2015-01-27 Kabushiki Kaisha Toshiba Automaton determinization method, device, and computer program product that involves a plurality of states and deleting states that are next states to first transitions
US9286891B2 (en) 2011-09-16 2016-03-15 Kabushiki Kaisha Toshiba Automaton determinization method, device, and computer program product involving deleting states
JP2013101565A (en) * 2011-11-09 2013-05-23 Fujitsu Ltd Automaton processing apparatus, automaton processing method and automaton processing program

Also Published As

Publication number Publication date
JP5077380B2 (en) 2012-11-21

Similar Documents

Publication Publication Date Title
JP4535130B2 (en) Character string collation device and character string collation program
JP6160259B2 (en) Character string search method, character string search device, and character string search program
JP5381710B2 (en) Nondeterministic finite automaton generation system, method and program without ε transition
JP4271227B2 (en) Bit string search device, search method and program
JP5473893B2 (en) Code string search device, search method and program
JP2005525625A (en) Computer representation by data structure and related encoding / decoding method
CN111027703A (en) Quantum line query method and device, storage medium and electronic device
JP5077380B2 (en) Character string collation device and character string collation program
KR100904835B1 (en) Character string checking device and computer-readable storage medium recording character string checking program
JP4402169B1 (en) Code string search device, search method and program
Idsardi Calculating metrical structure
KR101645890B1 (en) Method and Device for Reducing NFA
JP2012252475A (en) Processor, compression program, compression device, and compression method
JP2010225137A (en) Retrieval program and retrieval method
JP5807592B2 (en) Encoding method, encoding apparatus, and computer program
JP5041003B2 (en) Search device and search method
JP6898818B2 (en) Graph generator, graph generation method, data structure, and program
KR102146625B1 (en) Apparatus and method for computing incrementally infix probabilities based on automata
JP3761451B2 (en) Data structure for storing symbol string, symbol string search device, symbol string search method, program, and information recording medium
TWI443538B (en) Multi - hierarchical parallel multi - character string alignment device
JP2013257670A (en) Processor, compression apparatus, compression method, and compression program
JP4464459B1 (en) Code string search device, search method and program
JP2019159362A (en) Search program and search method
JP5696132B2 (en) Adaptive reconstruction apparatus, method, and program according to partial tree structure
JP4429373B1 (en) Code string search device, search method and program

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20120228

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20120427

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20120731

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120813

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150907

Year of fee payment: 3

R151 Written notification of patent or utility model registration

Ref document number: 5077380

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150907

Year of fee payment: 3

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250