JPWO2004088539A1 - Parsing method and programmable processor unit for parsing - Google Patents
Parsing method and programmable processor unit for parsing Download PDFInfo
- Publication number
- JPWO2004088539A1 JPWO2004088539A1 JP2004570163A JP2004570163A JPWO2004088539A1 JP WO2004088539 A1 JPWO2004088539 A1 JP WO2004088539A1 JP 2004570163 A JP2004570163 A JP 2004570163A JP 2004570163 A JP2004570163 A JP 2004570163A JP WO2004088539 A1 JPWO2004088539 A1 JP WO2004088539A1
- Authority
- JP
- Japan
- Prior art keywords
- data
- keyword
- flag
- memory
- stream
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/40—Information retrieval; Database structures therefor; File system structures therefor of multimedia data, e.g. slideshows comprising image and additional audio data
- G06F16/48—Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/40—Information retrieval; Database structures therefor; File system structures therefor of multimedia data, e.g. slideshows comprising image and additional audio data
Abstract
本発明に係る構文解析方法は、メモリにキーワードに対応したリファレンスデータとリファレンスデータに対応した参照先テーブルデータ及びフラグデータとから構成される1組のデータを複数組含むテーブルを複数組含むテーブルをアドレスデータに対応させて複数個用意する工程と、メモリから1つのテーブルを取出す工程と、ストリームデータからターゲットデータを抽出する工程と、ターゲットデータと取出したテーブルに含まれる複数組のデータの各リファレンスデータとを比較する工程と、ターゲットデータと一致したリファレンスデータに対応した参照先テーブルデータ及びフラグデータを選択する工程と、選択した参照先テーブルデータをアドレスデータとして利用してメモリから選択した参照先テーブルデータに対応したテーブルを出力する工程とを有する。In the syntax analysis method according to the present invention, a table including a plurality of sets of tables each including a plurality of sets of one set of reference data corresponding to a keyword, reference destination table data corresponding to the reference data, and flag data is stored in a memory. A step of preparing a plurality corresponding to the address data, a step of extracting one table from the memory, a step of extracting target data from the stream data, and each reference of the target data and a plurality of sets of data included in the extracted table A step of comparing the data, a step of selecting reference destination table data and flag data corresponding to the reference data matching the target data, and a reference destination selected from the memory using the selected reference destination table data as address data Corresponding to table data And a step of outputting the Buru.
Description
本発明は、MPEGなどのメディア・データ、多重化されたバイナリ・ストリームデータ及び文字列等のストリームデータから、所望のキーワードを探し出すための構文解析方法に関し、特に高速に処理を行うことができる構文解析方法にする。さらに本発明は、そのような構文解析のためのプログラマブル・プロセッサ・ユニットに関する。 The present invention relates to a parsing method for finding a desired keyword from media data such as MPEG, stream data such as multiplexed binary stream data and character strings, and the syntax that can be processed particularly at high speed. Use the analysis method. The invention further relates to a programmable processor unit for such parsing.
従来の構文解析では、検索を行いたいキーワードを一つ取出し、キーワードと検索対象のストリームデータとを、ストリームデータの先頭から最後に渡って比較していた。そして、一つのキーワードとストリームデータとの比較が終了すると、次のキーワードに関して次の比較を行うというように、処理を繰り返していた。
図13を用いて、従来の構文解析方法の手順について説明する。図13において、検索対象のストリームデータ1300(cabcdeaa・・・)が、バッファに格納されているものとする。また、検索したいキーワード1310(「abcd」、「cad」、「cae」及び「cd」)も、同様にバッファに格納されているものとする。最初に、キーワード「abcd」を取出し、検索1回目1320に示す様に、ストリームデータ1300の先頭から順に比較を行っていく。図13の例では、ストリームデータ1300の2文字目から5文字目と、キーワード「abcd」が一致している。引き続き、一致した事を何らかの手段によって保持しながら、ストリームデータ1300の6文字目から最後まで比較を行う。このようにして検索1回目1320を終了する。
次に、キーワード「cad」を取出し、検索2回目1330に示す様に、ストリームデータ1300の先頭から順に比較を行っていく。さらに、検索3回目1340、検索4回目1350の順で、キーワード1310の個数分だけ比較を継続して、全ての検索処理を終了する。
このような比較を高速に行う手法として、ハッシュ法がある。ハッシュ法とは、文字列からなる集合の要素からこの要素の格納場所のアドレスを求める関数(ハッシュ関数)を定義し、ハッシュ関数によって求められたアドレスをテーブルに格納するようにした方法である。ハッシュ法を利用した従来例が特開平4−96174号公報に記載されている。その従来例では、候補文字列の読出し手段と一致検索手段とを独立して動作するように構成して、比較の高速化を図っている。
しかしながら、従来の構文解析では、比較を行うキーワードが複数ある場合に、キーワードの数に比例して検索時間が増大してしまうという問題があった。また、検索対象のストリームデータが全て揃っていないと、構文解析を始められないという問題もあった。さらに、キーワードは通常固定されて設定されており、容易に変更することができないという問題もあった。
発明の要約
そこで、本発明は、予め登録し且つテーブル展開しておいた全てのキーワードに対して、ストリームデータから抽出されたターゲットデータとの比較を並行して行い、キーワードが複数あっても高速に検索することができる構文解析方法及びそのような構文解析のためのプログラマブル・プロセッサ・ユニットを提供することを目的とする。
また、本発明は、検索対象のストリームデータが全て揃っていなくても検索を行うことができる構文解析方法及びそのような構文解析のためのプログラマブル・プロセッサ・ユニットを提供することを目的とする。
上記目的を達成するために、本発明に係る構文解析方法は、メモリにキーワードに対応したリファレンスデータとリファレンスデータに対応した参照先テーブルデータ及びフラグデータとから構成される1組のデータを複数組含むテーブルをアドレスデータに対応させて複数個用意する工程と、メモリから1つのテーブルを取出す工程と、ストリームデータからターゲットデータを抽出する工程と、ターゲットデータと取出したテーブルに含まれる複数組のデータの各リファレンスデータとを比較する工程と、ターゲットデータと一致したリファレンスデータに対応した参照先テーブルデータ及びフラグデータを選択する工程と、選択した参照先テーブルデータをアドレスデータとして利用してメモリから選択した参照先テーブルデータに対応したテーブルを出力する工程とを有し、抽出工程、比較工程、選択工程及び出力工程を、ストリームデータを構成するデータを順次新たなターゲットデータとして抽出しながら、繰返し行うことによってストリームデータからキーワードを検出することを特徴とする。
本発明に係る構文解析方法では、ストリームデータから1データずつをターゲットデータとして抽出し、メモリ上にテーブル展開されたキーワードとの比較を順次行っていくので、検索対象のストリームデータが最後まで揃っていない場合でも、ストリームデータの先頭から存在する分だけでも構文解析に着手することができる。また、検索対象のストリームデータが途中で追加されても、容易に構文解析を再開又は続行することができる。さらに、検索したいキーワードが複数ある場合でも、メモリ上に全てのキーワードをテーブル展開することによって、全てのキーワードの検索を同時並行的に処理することができる。
また、上記目的を達成するために、本発明に係るプログラマブル・プロセッサ・ユニットは、ストリームデータから抽出されたターゲットデータを記憶するレジスタと、キーワードに対応したリファレンスデータとリファレンスデータに対応した参照先テーブルデータ及びフラグデータとから構成される1組のデータを複数組有するテーブルセットを複数記憶し、アドレスデータの入力に応じてアドレスデータに対応したテーブルセットを出力するメモリと、メモリから1つのテーブルセットが有する複数組のデータを入力して、ターゲットデータと複数組のデータの各リファレンスデータとを比較し、一致した場合に、一致したリファレンスデータに対応した参照先テーブルデータ及びフラグデータを選択し、選択した参照先テーブルデータに対応したテーブルセットをメモリから入力するために、選択した参照先テーブルデータをアドレスデータとして出力する処理回路とを有することを特徴とする。
本発明に係るプログラマブル・プロセッサ・ユニットは、前述した本発明に係る構文解析方法を実現するためのユニットである。また、検索したいキーワードをプログラム設定可能としたので、入来するストリームデータの仕様に応じて、キーワードを容易に変更することが可能となる。また、検索したいキーワードが複数ある場合でも、全てのキーワードの検索を同時並行的に処理することができる。In the conventional syntax analysis, one keyword to be searched is taken out, and the keyword and stream data to be searched are compared from the beginning to the end of the stream data. When the comparison between one keyword and stream data is completed, the process is repeated such that the next comparison is performed for the next keyword.
The procedure of the conventional syntax analysis method will be described with reference to FIG. In FIG. 13, it is assumed that stream data 1300 (cabcdea...) To be searched is stored in the buffer. Also, it is assumed that the keyword 1310 (“abcd”, “cad”, “cae”, and “cd”) to be searched is also stored in the buffer. First, the keyword “abcd” is extracted, and as shown in the
Next, the keyword “cad” is taken out and compared as shown in the
As a technique for performing such comparison at high speed, there is a hash method. The hash method is a method in which a function (hash function) for obtaining an address of a storage location of an element is defined from elements of a set of character strings, and the address obtained by the hash function is stored in a table. A conventional example using the hash method is described in Japanese Patent Laid-Open No. 4-96174. In the conventional example, the candidate character string reading means and the match search means are configured to operate independently to increase the speed of comparison.
However, the conventional parsing has a problem that the search time increases in proportion to the number of keywords when there are a plurality of keywords to be compared. There is also a problem that the parsing cannot be started unless all the stream data to be searched is prepared. Furthermore, there is a problem that keywords are usually fixed and set and cannot be easily changed.
SUMMARY OF THE INVENTION Therefore, the present invention compares all the keywords registered in advance and developed in the table with the target data extracted from the stream data in parallel. It is an object of the present invention to provide a parsing method and a programmable processor unit for such parsing.
It is another object of the present invention to provide a syntax analysis method capable of performing a search even when all the stream data to be searched is not available, and a programmable processor unit for such syntax analysis.
In order to achieve the above object, a syntax analysis method according to the present invention includes a plurality of sets of data each composed of reference data corresponding to a keyword, reference destination table data corresponding to the reference data, and flag data in a memory. A step of preparing a plurality of tables corresponding to address data, a step of extracting one table from a memory, a step of extracting target data from stream data, and a plurality of sets of data included in the extracted table of target data A step of comparing each of the reference data, a step of selecting reference destination table data and flag data corresponding to the reference data that matches the target data, and selecting from the memory using the selected reference destination table data as address data For the referenced table data A process of outputting the table, and by repeating the extraction process, the comparison process, the selection process, and the output process while sequentially extracting the data constituting the stream data as new target data, keywords are extracted from the stream data. It is characterized by detecting.
In the parsing method according to the present invention, each piece of data is extracted as target data from the stream data and sequentially compared with keywords expanded in a table on the memory. Even if not, syntax analysis can be started only by the amount existing from the beginning of the stream data. Moreover, even if stream data to be searched is added in the middle, parsing can be easily resumed or continued. Furthermore, even when there are a plurality of keywords to be searched, by searching all the keywords on the memory, a search for all the keywords can be processed in parallel.
In order to achieve the above object, a programmable processor unit according to the present invention includes a register for storing target data extracted from stream data, reference data corresponding to a keyword, and a reference table corresponding to the reference data. A plurality of table sets each including a plurality of sets of data and flag data, a memory that outputs a table set corresponding to the address data in response to input of the address data, and one table set from the memory A plurality of sets of data is input, the target data is compared with each reference data of the plurality of sets of data, and if they match, the reference table data and flag data corresponding to the matched reference data are selected, Selected reference table data The table set corresponding to the input from memory, and having a processing circuit for outputting a referenced table data selected as the address data.
The programmable processor unit according to the present invention is a unit for realizing the syntax analysis method according to the present invention described above. Further, since the keyword to be searched can be set as a program, the keyword can be easily changed according to the specifications of the incoming stream data. Further, even when there are a plurality of keywords to be searched, it is possible to process searching for all keywords simultaneously.
図1は、本発明に係わる構文解析方法の全体の手順を示すフローチャートである。
図2は、キーワードのテーブル展開の手順を説明するための図である。
図3は、テーブル展開されたデータの一例を示す図である。
図4は、データストリームの検索の手順の概略を説明するための図である。
図5は、データストリームの検索の一例を示す図である。
図6は、データストリームの検索の一例を示す図である。
図7は、データストリームの検索の一例を示す図である。
図8は、データストリームの検索の一例を示す図である。
図9は、データストリームの検索の一例を示す図である。
図10は、メモリに格納されるテーブルの一例を示す図である。
図11は、本発明に係るプログラマブル・プロセッサ・ユニットの概略構成を示す図である。
図12は、図11に示す処理回路の概略回路構成を示す図である。
図13は、従来の構文解析方法を説明するための図である。FIG. 1 is a flowchart showing the overall procedure of the syntax analysis method according to the present invention.
FIG. 2 is a diagram for explaining a procedure for expanding a keyword table.
FIG. 3 is a diagram illustrating an example of data developed in a table.
FIG. 4 is a diagram for explaining an outline of a procedure for searching a data stream.
FIG. 5 is a diagram illustrating an example of data stream search.
FIG. 6 is a diagram illustrating an example of data stream search.
FIG. 7 is a diagram illustrating an example of data stream search.
FIG. 8 is a diagram illustrating an example of data stream search.
FIG. 9 is a diagram illustrating an example of data stream search.
FIG. 10 is a diagram illustrating an example of a table stored in the memory.
FIG. 11 is a diagram showing a schematic configuration of a programmable processor unit according to the present invention.
FIG. 12 is a diagram showing a schematic circuit configuration of the processing circuit shown in FIG.
FIG. 13 is a diagram for explaining a conventional syntax analysis method.
図1は、本発明に係る構文解析方法の手順を示すフローチャートである。本発明に係る構文解析方法では、検索対象となるデータストリームから、予めテーブル展開されたキーワードの検索を行い、検索結果を出力することができるように構成されている。
以下に、データストリームとして以下の8通りの文字が使用されている文字列を用い、4種類のキーワード(「abcd」、「cad」、「cae」及び「cd」)の検索を行う場合を例にして説明を行う。
文字コード data
0000 a
0001 b
0002 c
0003 d
0004 e
0005 f
0006 g
0007 h
最初に、テーブルの総数、ポインタ配列の深さを定義し、テーブルの初期化を行う(ステップ101)。ここでは、テーブル総数は6、ポインタ配列の深さN=10に設定した。
次に、登録するキーワードの総数を定義し、キーワードの初期化を行う(ステップ102)。ここでは、キーワードの総数を4に設定した。
次に、検索を行うキーワードを一つずつ登録し、テーブル展開する(ステップ103)。図2に、キーワード「cae」を登録し、テーブル展開を行う例を示す。
図2では、キーワード「abcd」は既に登録されているものとする。キーワード「abcd」の登録により、先頭文字テーブル200、2番目の文字テーブル210、3番目の文字テーブル220及び4番目の文字テーブル230が作成されている。各テーブルには、図示されるようなアドレスデータが対応しており、リファレンスデータ、参照先テーブルデータ及びフラグデータから構成される1組のデータを複数含んでいる。また、リファレンスデータは、検索対象の文字列を構成している8種の文字に対応している。なお、各テーブルにおいて、参照先テーブルデータの初期値は[0x0000]、またフラグデータの初期値は[unmatch]に設定されている。
まず、先頭文字テーブル200において、キーワード「cae」の先頭文字に応じて、リファレンスデータ「c」に対応する参照先テーブルデータを[0x0004]に変更し、リファレンスデータ「c」に対応するフラグデータを[continue]に変更する。
次に、キーワード「cae」の2番目の文字及び参照先テーブルデータの[0x0004]に対応して、新たに2番目の文字テーブルとして240を作成する。さらに、2番目のテーブル240のリファレンスデータ「a」に対応する参照先テーブルデータを[0x0005]に変更し、リファレンスデータ「a」に対応するフラグデータを[continue]に変更する。
次に、キーワード「cae」の3番目の文字及び参照先テーブルデータの[0x0005]に対応して、新たに3番目の文字テーブルとして250を作成する。さらに、3番目のテーブル250のリファレンスデータ「e」に対応するフラグデータを[match]に変更して、キーワード「cae」の登録を完了する。
同様に、キーワード「cae」及び「cd」の登録を行う。全てのキーワードの登録及びテーブル展開を完了した後の複数のテーブルセットを図3に示す。図3に示す複数のテーブルセットは、先頭文字テーブル300、2番目の文字テーブル310及び340、3番目の文字テーブル320及び340、4番目の文字テーブル350から構成されている。
次に、全てのキーワードの登録及びテーブル展開を完了した後の複数のテーブルセットの表示を適当なディスプレイ上で行う(ステップ104)。複数のテーブルセットの表示は、デバックのためのものであり、不必要な場合には省略することも可能である。
次に、検索対象の文字列からキーワードの検索を実行する(ステップ105)。図4に、検索の手順の概略を示す。ここでは、検索対象の文字列が「cabcde・・・」であるものとする。最初に、検索対象の文字列から最初の一文字「c」をターゲットデータとして抽出し、「c」と4つのキーワードの最初の一文字目との比較を行う(401)。ターゲットデータ「c」とキーワード「cad」、「cae」及び「cd」の一文字目が一致するので、これらのキーワードは継続したものとする。
次に、検索対象の文字列の次の一文字「a」をターゲットデータとして抽出し、「a」と4つのキーワードとの比較を行う(402)。ターゲットデータ「a」とキーワード「cad」及び「cae」の2文字目が一致するので、これらのキーワードは継続したものとする。また、キーワード「cd」の2文字目は「a」でないので、これらは一致しない。さらに、ターゲットデータ「a」とキーワード「abcd」の一文字目が一致するので、このキーワードは継続したものとする。
次に、検索対象の文字列の次の一文字「b」をターゲットデータとして抽出し、「b」と4つのキーワードとの比較を行う(403)。ターゲットデータ「b」とキーワード「abcd」の2文字目が一致するので、このキーワードは継続しているものとする。また、キーワード「cad」及び「cae」の3文字目は「b」でないので、これらは一致しない。
次に、検索対象の文字列の次の一文字「c」をターゲットデータとして抽出し、「c」と4つのキーワードとの比較を行う(404)。ターゲットデータ「c」とキーワード「abcd」の3文字目は一致するので、このキーワードは継続したものとする。さらに、ターゲットデータ「c」とキーワード「cad」、「cae」及び「cd」の一文字目は一致するので、これらのキーワードは継続したものとする。
次に、検索対象の文字列の次の一文字「d」をターゲットデータとして抽出し、「d」と4つのキーワードとの比較を行う(405)。ターゲットデータ「d」とキーワード「abcd」の4文字目は一致するので、このキーワードは文字列中に検出されたものとする。また、キーワード「cad」及び「cae」の2文字目は「d」でないので、これらのキーワードは一致しない。さらに、キーワード「cd」の2文字目は「d」であるが、キーワード「abcd」が一致しているので、キーワード「cd」は無効とする。
このようにして、検索対象の文字列から一文字ずつ抽出して、全てのキーワードとの比較を同時並行的に行う処理を、検索対象の文字列の全てについて行う。
次に、図5〜図9を用いて、上述した検索処理を、複数のテーブルセットとポインタを用いてどのように実行するかを説明する。
最初に、検索対象の文字列からターゲットデータとして「c」を取出して比較を行う(図5参照)。まず、ポインタの0階層に初期設定されている[0x0000]に基づいてテーブル300を選択して(501)、ターゲットデータ「c」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「c」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0004]をポインタに格納する(502)。したがって、最初のターゲットデータ「c」との比較後には、ポインタは、ポインタ(後)370のように設定されている。なお、ポインタの最下位層には、常に[0x0000]が設定される。
次に、検索対象の文字列から次のターゲットデータ「a」を取出して、比較を行う(図6参照)。この時ポインタは、図5の結果からポインタ(前)360のように設定されている。まず。ポインタの第0階層に設定されている[0x0004]に基づいてテーブル340を選択して(601)、ターゲットデータ「a」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「a」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0005]をポインタに格納する(602)。次に、ポインタの第1階層に設定されている[0x0000]に基づいてテーブル300を選択して(603)、ターゲットデータ「a」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「a」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0001]をポインタに格納する(604)。したがって、ターゲットデータ「a」との比較後には、ポインタは、ポインタ(後)370のように設定されている。
次に、検索対象の文字列から次のターゲットデータ「b」を取出して、比較を行う(図7参照)。この時ポインタは、図6の結果からポインタ(前)360のように設定されている。まず。ポインタの第0階層に設定されている[0x0005]に基づいてテーブル350を選択して(701)、ターゲットデータ「b」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「b」のフラグデータが[unmatch]であるので、ポインタへの格納はしない。次に、ポインタの第1階層に設定されている[0x0001]に基づいてテーブル310を選択して(702)、ターゲットデータ「b」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「a」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0002]をポインタに格納する(703)。次に、ポインタの第2階層に設定されている[0x0000]に基づいてテーブル300を選択して(704)、ターゲットデータ「b」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「b」のフラグデータが[unmatch]であるので、ポインタへの格納はしない。したがって、ターゲットデータ「b」との比較後には、ポインタは、ポインタ(後)370のように設定されている。
次に、検索対象の文字列から次のターゲットデータ「c」を取出して、比較を行う(図8参照)。この時ポインタは、図7の結果からポインタ(前)360のように設定されている。まず、ポインタの第0階層に設定されている[0x0002]に基づいてテーブル320を選択して(801)、ターゲットデータ「c」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「c」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0003]をポインタに格納する(802)。次に、ポインタの第1階層に設定されている[0x0000]に基づいてテーブル300を選択して(803)、ターゲットデータ「c」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「c」のフラグデータが[continue]であるので、参照先テーブルデータ[0x0004]をポインタに格納する(804)。したがって、ターゲットデータ「c」との比較後には、ポインタは、ポインタ(後)370のように設定されている。
次に、検索対象の文字列から次のターゲットデータ「d」を取出して、比較を行う(図9参照)。この時ポインタは、図8の結果からポインタ(前)360のように設定されている。まず。ポインタの第0階層に設定されている[0x0003]に基づいてテーブル330を選択して(901)、ターゲットデータ「d」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「d」のフラグデータが[match]であるので、キーワード「abcd」が検出されたことが判別される。次に、ポインタの第1階層に設定されている[0x0004]に基づいてテーブル340を選択して(902)、ターゲットデータ「d」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「d」のフラグデータが[match]であるが同レベルでキーワード「abcd」が検出されていることから、キーワード「cd」の検出を無効とする。次に、ポインタの第2階層に設定されている[0x0000]に基づいてテーブル300を選択して(903)、ターゲットデータ「d」とリファレンスデータ「a」〜「f」を比較し、一致したリファレンスデータ「d」のフラグデータが[unmatch]であるので、ポインタへの格納はしない。したがって、ターゲットデータ「d」との比較後には、ポインタは、ポインタ(後)370のように設定されている。
このようにして、検索対象の文字列から1文字ずつターゲットデータを抽出しながら、検索対象の文字列の最後まで、キーワードとの比較を行っていく。したがって、本発明に係る構文解析方法では、検索対象の文字列が最後まで揃っていない場合でも、文字列の先頭から存在する分だけでも構文解析に着手することができる。また、検索対象の文字列が途中で追加されても、容易に構文解析を再開又は続行することができる。さらに、検索したいキーワードが複数ある場合でも、全てのキーワードの検索を同時並行的に処理することができる。
次に、図10〜12を用いて、前述した本発明に係る構文解析方法を効率良く実現するためのプログラマブル・プロセッサ・ユニットについて説明を行う。
図10に、本発明に係るプログラマブル・プロセッサ・ユニット1000の概略を示す。なお、図10に示すプログラマブル・プロセッサ・ユニット1000は、一例であって、これに限定されるものでは無い。図示されるように、プログラマブル・プロセッサ・ユニット1000は、処理回路1002、ターゲットレジスタ1004、遅延回路1006及びメモリ1008から構成されている。
プログラマブル・プロセッサ・ユニット1000では、検索対象の文字列1010がターゲットレジスタ1004に入力され、一文字ずつターゲットデータ1012として処理回路1002に入力される。処理回路1002では、NEXTアドレス信号1014を出力して遅延回路1006に一次記憶させる。また、所定のタイミングでアドレス信号1016がメモリ1008に入力される。メモリ1008には後述する複数のテーブルセットが予め記憶され、アドレス信号1016に対応したテーブルセットに含まれる複数組のデータ1018(リファレンスデータ[n]、参照先テーブルデータ[n]、有効バイトデータ[n]及びフラグデータ[n])が処理回路1002に入力される。処理回路1002では、前述した構文解析方法に基づく理論に従って、ターゲットデータ1012及びテーブルセットに含まれる複数組のデータ1018を用いて、NEXTアドレス信号1014及びフラグデータ1020を出力するように構成されている。
次に、メモリ1008に記憶されている複数のテーブルセットについて説明する。複数のテーブルセットは、前述した図3に示されるような6つのテーブルセット300〜350であって良い。しかしながら、利用しない項目を圧縮して、図11に示すようなテーブルセットを作成することもできる。図11において、テーブルセット例1100は、アドレスデータ1102、リファレンスデータ1104、参照先テーブルデータ1106、有効バイトデータ1108及びフラグデータ1110から構成されている。なお、有効バイトデータ1108は、対応するリファレンスデータの比較が必要か否かを示すデータである。
図11に示すテーブルセットを利用すれば、一度に処理する組データ(リファレンスデータ[n]、参照先テーブルデータ[n]、有効バイトデータ[n]及びフラグデータ[n])は、4組ずつで良くなり、ハードウエアの構成を簡素化することが可能となる。
次に、処理回路1002の回路構成の概略を図12に示す。図12に示す処理回路1002は、図11に示すテーブルセット1100を利用した場合に適合しており、一度に4つの組データを処理することができる。
処理回路1002の主要部は、図12に示すように、アドレスデコーダ1200、コンパレータ1202、1208、1214及び1220、インバータ1204、1210、1216及び1222、OR回路1206、1212、1218及び1224、プライオリティ・エンコーダ1226、第1出力バッファ1228、及び第2出力バッファ1230から構成される。処理回路1002は、有効バイトが1ビットの場合に4リファレンスデータを同時比較する理論に基づいて構成されている。
処理回路1002は、メモリ1008からアドレスデータに対応した4つの組データ(リファレンスデータ[n]、参照先テーブルデータ[n]、有効バイトデータ[n]及びフラグデータ[n])を同時に参照する。図12において、参照した4つの組データを1240として示す。
各行のリファレンスデータ[0]〜[3]は、アドレスデコーダ1200によってデコードされてコンパレータ1202、1208、1214及び1220に入力されて、ターゲットデータと比較される。デコードされたリファレンスデータがターゲットデータと一致する場合には、ハイレベルがコンパレータから出力されるように構成されている。
各行の有効バイトデータ[0]〜[3]は、デコードされて、インバータ1204、1210、1216及び1222にそれぞれ入力される。したがって、有効バイトデータが”valid”の場合は各インバータからはローベルが出力され、有効バイトデータが”invalid”の場合は各インバータからはハイベルが出力される。
各参照先テーブルデータ[0]〜[3]は、第1の出力バッファ1228に格納され、各フラグデータ[0]〜[3]は、第2の出力バッファ1230に格納される。
インバータ出力がローベルの場合、OR回路は、コンパレータからの出力がハイレベルの場合にハイレベルの出力を行う。即ち、この場合、デコードされたリファレンスデータとターゲットデータが一致したこととなる。また、インバータ出力がハイレベルの場合、OR回路は、無条件でハイレベルの出力を行う。
プライオリティ・デコーダ1226は、OR回路からハイレベルの出力がなされた組の参照先テーブルデータを第1出力バッファ1228からnextアドレスデータ1014として出力し、同様にOR回路からハイレベルの出力がなされた組のフラグデータを第2出力バッファからフラグデータ1020として出力する。
第1出力バッファから出力されたnextアドレスデータ1014は、遅延回路1006で一旦保持され、次のシーケンスを待つこととなる。また次のシーケンスでは、次のターゲットデータにアップデートされて、同様の処理が行われる。なお、文字列の全てについての処理が完了するまで、シーケンスは繰り返される。このようにして、全文字列に対して、キーワードが存在するか否かの検索が行われる。
このようにストリームデータ中に予めメモリ1008にテーブル展開されたキーワードが存在するか否かを高速に検索することが可能となった。特に、本プログラマブル・プロセッサ・ユニットを利用すれば、検索対象のストリームデータが最後まで揃っていない場合でも、先頭から存在する分だけでも構文解析に着手することができる。さらに、データストリームが途中で追加されても、容易に構文解析を再開又は続行することができる。さらに、検索したいキーワードが複数ある場合でも、全てのキーワードの検索を同時並行的に処理することができる。したがって、通信手段を用いて、MPEGなどの画像データと制御データとが混在するストリームデータを順次受信している場合に、そのようなストリームデータから制御データのみを検索する場合等に特に本発明は有効である。
また、キーワードは容易にメモリ上にプログラム設定することができるので、予め複数グループのキーワードをテーブル展開してメモリ上に記憶させておき、入来するストリームデータに応じて、検索するキーワードを切替えることも可能である。FIG. 1 is a flowchart showing a procedure of a syntax analysis method according to the present invention. The syntax analysis method according to the present invention is configured so that a keyword expanded in a table in advance is searched from a data stream to be searched, and a search result is output.
The following is an example in which a search is performed for four types of keywords (“abcd”, “cad”, “cae”, and “cd”) using a character string that uses the following eight characters as a data stream: I will explain.
Character code data
0000 a
0001 b
0002 c
0003 d
0004 e
0005 f
0006 g
0007 h
First, the total number of tables and the depth of the pointer array are defined, and the table is initialized (step 101). Here, the total number of tables is set to 6, and the depth N of the pointer array is set to 10.
Next, the total number of keywords to be registered is defined, and keyword initialization is performed (step 102). Here, the total number of keywords is set to 4.
Next, keywords to be searched are registered one by one and developed in a table (step 103). FIG. 2 shows an example in which the keyword “cae” is registered and table expansion is performed.
In FIG. 2, it is assumed that the keyword “abcd” has already been registered. By registering the keyword “abcd”, the first character table 200, the second character table 210, the third character table 220, and the fourth character table 230 are created. Each table corresponds to address data as illustrated, and includes a plurality of sets of data including reference data, reference table data, and flag data. Further, the reference data corresponds to eight types of characters constituting the character string to be searched. In each table, the initial value of the reference table data is set to [0x0000], and the initial value of the flag data is set to [unmatch].
First, in the first character table 200, the reference table data corresponding to the reference data “c” is changed to [0x0004] according to the first character of the keyword “cae”, and the flag data corresponding to the reference data “c” is changed. Change to [continue].
Next, 240 is newly created as the second character table corresponding to the second character of the keyword “cae” and the reference table data [0x0004]. Further, the reference table data corresponding to the reference data “a” in the second table 240 is changed to [0x0005], and the flag data corresponding to the reference data “a” is changed to [continue].
Next, 250 is newly created as the third character table corresponding to the third character of the keyword “cae” and the reference table data [0x0005]. Further, the flag data corresponding to the reference data “e” in the third table 250 is changed to [match], and the registration of the keyword “cae” is completed.
Similarly, the keywords “cae” and “cd” are registered. A plurality of table sets after registration of all keywords and table expansion are shown in FIG. The plurality of table sets shown in FIG. 3 includes a first character table 300, a second character table 310 and 340, a third character table 320 and 340, and a fourth character table 350.
Next, a plurality of table sets are displayed on an appropriate display after registration of all keywords and table expansion are completed (step 104). The display of the plurality of table sets is for debugging, and can be omitted if unnecessary.
Next, a keyword search is executed from the character string to be searched (step 105). FIG. 4 shows an outline of the search procedure. Here, it is assumed that the character string to be searched is “cabcde...”. First, the first character “c” is extracted as target data from the search target character string, and “c” is compared with the first character of the four keywords (401). Since the first character of the target data “c” and the keywords “cad”, “cae”, and “cd” match, these keywords are assumed to have continued.
Next, the next character “a” of the character string to be searched is extracted as target data, and “a” is compared with the four keywords (402). Since the target data “a” and the second characters of the keywords “cad” and “cae” match, it is assumed that these keywords have continued. Further, since the second character of the keyword “cd” is not “a”, they do not match. Further, since the first character of the target data “a” and the keyword “abcd” match, this keyword is assumed to be continued.
Next, the next character “b” of the search target character string is extracted as target data, and “b” is compared with the four keywords (403). Since the second character of the target data “b” and the keyword “abcd” match, it is assumed that the keyword continues. Further, since the third characters of the keywords “cad” and “cae” are not “b”, they do not match.
Next, the next character “c” of the character string to be searched is extracted as target data, and “c” is compared with the four keywords (404). Since the third character of the target data “c” and the keyword “abcd” match, this keyword is assumed to be continued. Furthermore, since the target data “c” and the first characters of the keywords “cad”, “cae”, and “cd” match, it is assumed that these keywords continue.
Next, the next character “d” of the character string to be searched is extracted as target data, and “d” is compared with the four keywords (405). Since the fourth character of the target data “d” and the keyword “abcd” match, it is assumed that this keyword is detected in the character string. Further, since the second characters of the keywords “cad” and “cae” are not “d”, these keywords do not match. Further, the second character of the keyword “cd” is “d”, but since the keyword “abcd” matches, the keyword “cd” is invalidated.
In this way, the process of extracting characters one by one from the search target character string and performing comparison with all the keywords simultaneously is performed for all the search target character strings.
Next, using FIG. 5 to FIG. 9, how the above-described search process is executed using a plurality of table sets and pointers will be described.
First, “c” is extracted as target data from the character string to be searched for comparison (see FIG. 5). First, the table 300 is selected based on [0x0000] initially set in the 0th hierarchy of the pointer (501), the target data “c” is compared with the reference data “a” to “f”, and the matched reference is selected. Since the flag data of the data “c” is [continue], the reference table data [0x0004] is stored in the pointer (502). Therefore, after the comparison with the first target data “c”, the pointer is set like a pointer (rear) 370. [0x0000] is always set in the lowest layer of the pointer.
Next, the next target data “a” is extracted from the character string to be searched and compared (see FIG. 6). At this time, the pointer is set as a pointer (previous) 360 from the result of FIG. First. The table 340 is selected based on [0x0004] set in the 0th layer of the pointer (601), the target data “a” is compared with the reference data “a” to “f”, and the matched reference data “ Since the flag data of “a” is [continue], the reference table data [0x0005] is stored in the pointer (602). Next, the table 300 is selected based on [0x0000] set in the first layer of the pointer (603), the target data “a” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “a” is [continue], reference destination table data [0x0001] is stored in the pointer (604). Therefore, after the comparison with the target data “a”, the pointer is set as a pointer (after) 370.
Next, the next target data “b” is extracted from the character string to be searched and compared (see FIG. 7). At this time, the pointer is set as a pointer (front) 360 from the result of FIG. First. The table 350 is selected based on [0x0005] set in the 0th hierarchy of the pointer (701), the target data “b” is compared with the reference data “a” to “f”, and the matched reference data “ Since the flag data of “b” is [unmatch], it is not stored in the pointer. Next, the table 310 is selected based on [0x0001] set in the first layer of the pointer (702), the target data “b” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “a” is [continue], the reference table data [0x0002] is stored in the pointer (703). Next, the table 300 is selected based on [0x0000] set in the second layer of the pointer (704), the target data “b” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “b” is “unmatch”, it is not stored in the pointer. Therefore, after the comparison with the target data “b”, the pointer is set as a pointer (rear) 370.
Next, the next target data “c” is extracted from the character string to be searched and compared (see FIG. 8). At this time, the pointer is set as a pointer (previous) 360 from the result of FIG. First, the table 320 is selected based on [0x0002] set in the 0th hierarchy of the pointer (801), the target data “c” is compared with the reference data “a” to “f”, and the matched reference is obtained. Since the flag data of the data “c” is [continue], the reference table data [0x0003] is stored in the pointer (802). Next, the table 300 is selected based on [0x0000] set in the first layer of the pointer (803), the target data “c” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “c” is [continue], the reference destination table data [0x0004] is stored in the pointer (804). Therefore, after the comparison with the target data “c”, the pointer is set as a pointer (rear) 370.
Next, the next target data “d” is extracted from the search target character string and compared (see FIG. 9). At this time, the pointer is set as a pointer (previous) 360 from the result of FIG. First. The table 330 is selected based on [0x0003] set in the 0th layer of the pointer (901), the target data “d” is compared with the reference data “a” to “f”, and the matched reference data “ Since the flag data of “d” is [match], it is determined that the keyword “abcd” has been detected. Next, the table 340 is selected based on [0x0004] set in the first layer of the pointer (902), the target data “d” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “d” is [match] but the keyword “abcd” is detected at the same level, the detection of the keyword “cd” is invalidated. Next, the table 300 is selected based on [0x0000] set in the second layer of the pointer (903), the target data “d” is compared with the reference data “a” to “f”, and they match. Since the flag data of the reference data “d” is “unmatch”, it is not stored in the pointer. Therefore, after the comparison with the target data “d”, the pointer is set as a pointer (rear) 370.
In this manner, the target data is extracted character by character from the character string to be searched, and the comparison with the keyword is performed up to the end of the character string to be searched. Therefore, in the syntax analysis method according to the present invention, even when the character strings to be searched are not prepared to the end, the syntax analysis can be started only by the amount existing from the top of the character string. Even if a search target character string is added in the middle, parsing can be easily resumed or continued. Furthermore, even when there are a plurality of keywords to be searched, it is possible to process all keyword searches in parallel.
Next, a programmable processor unit for efficiently realizing the syntax analysis method according to the present invention described above will be described with reference to FIGS.
FIG. 10 shows an outline of a
In the
Next, a plurality of table sets stored in the
If the table set shown in FIG. 11 is used, four sets of set data (reference data [n], reference destination table data [n], valid byte data [n], and flag data [n]) to be processed at a time are used. And the hardware configuration can be simplified.
Next, an outline of a circuit configuration of the
As shown in FIG. 12, the main part of the
The
The reference data [0] to [3] of each row is decoded by the
Valid byte data [0] to [3] of each row are decoded and input to
Each reference table data [0] to [3] is stored in the
When the inverter output is low level, the OR circuit outputs a high level when the output from the comparator is high level. That is, in this case, the decoded reference data matches the target data. Further, when the inverter output is at a high level, the OR circuit outputs a high level unconditionally.
The
The
As described above, it is possible to search at high speed whether there is a keyword previously expanded in the
In addition, since keywords can be easily programmed in the memory, a plurality of groups of keywords are expanded in a table and stored in the memory in advance, and the keyword to be searched is switched according to the incoming stream data. Is also possible.
Claims (7)
メモリに、前記キーワードに対応したリファレンスデータと、前記リファレンスデータに対応した参照先テーブルデータ及びフラグデータとから構成される1組のデータを複数組含むテーブルをアドレスデータに対応させて複数個用意する工程と、
前記メモリから1つのテーブルを取出す工程と、
前記ストリームデータからターゲットデータを抽出する工程と、
前記ターゲットデータと取出したテーブルに含まれる複数組のデータの各リファレンスデータとを比較する工程と、
前記ターゲットデータと一致したリファレンスデータに対応した参照先テーブルデータ及びフラグデータを選択する工程と、
選択した参照先テーブルデータをアドレスデータとして利用して、前記メモリから選択した参照先テーブルデータに対応したテーブルを出力する工程とを有し、
前記抽出工程、前記比較工程、前記選択工程及び前記出力工程を、前記ストリームデータを構成するデータを順次新たなターゲットデータとして抽出しながら、繰返し行うことによって前記ストリームデータから前記キーワードを検出することを特徴とする構文解析方法。In the syntax analysis method for detecting keywords from stream data to be searched,
A plurality of tables corresponding to the address data are prepared in the memory in correspondence with the address data. The table includes a plurality of sets of one set of reference data corresponding to the keyword, reference destination table data corresponding to the reference data, and flag data. Process,
Removing one table from the memory;
Extracting target data from the stream data;
A step of comparing the target data with each reference data of a plurality of sets of data included in the extracted table;
Selecting reference table data and flag data corresponding to reference data that matches the target data;
Using the selected reference table data as address data, and outputting a table corresponding to the selected reference table data from the memory,
Detecting the keyword from the stream data by repeatedly performing the extraction step, the comparison step, the selection step, and the output step while sequentially extracting data constituting the stream data as new target data. Character parsing method.
前記ストリームデータから抽出されたターゲットデータを記憶するレジスタと、
前記キーワードに対応したリファレンスデータと、前記リファレンスデータに対応した参照先テーブルデータ及びフラグデータとから構成される1組のデータを複数組有するテーブルを複数個記憶し、アドレスデータの入力に応じて前記アドレスデータに対応したテーブルを出力するメモリと、
前記メモリから1つのテーブルセットが有する複数組のデータを入力して、前記ターゲットデータと前記複数組のデータの各リファレンスデータとを比較し、一致した場合に、一致したリファレンスデータに対応した参照先テーブルデータ及びフラグデータを選択し、選択した参照先テーブルデータに対応したテーブルを前記メモリから入力するために、前記選択した参照先テーブルデータをアドレスデータとして出力する処理回路とを有することを特徴とするプログラマブル・プロセッサ・ユニット。In a programmable processor unit for detecting programmable keywords from stream data,
A register for storing target data extracted from the stream data;
A plurality of tables having a plurality of sets of one set of data composed of reference data corresponding to the keyword and reference destination table data and flag data corresponding to the reference data are stored, and the table according to the input of address data A memory that outputs a table corresponding to the address data; and
When a plurality of sets of data included in one table set are input from the memory, the target data and each reference data of the plurality of sets of data are compared, and if they match, the reference destination corresponding to the matched reference data A processing circuit for selecting table data and flag data and outputting the selected reference table data as address data in order to input a table corresponding to the selected reference table data from the memory; Programmable processor unit.
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/JP2003/004088 WO2004088539A1 (en) | 2003-03-31 | 2003-03-31 | Parsing method and programmable processor unit for parsing |
Publications (1)
Publication Number | Publication Date |
---|---|
JPWO2004088539A1 true JPWO2004088539A1 (en) | 2006-07-06 |
Family
ID=33105345
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2004570163A Pending JPWO2004088539A1 (en) | 2003-03-31 | 2003-03-31 | Parsing method and programmable processor unit for parsing |
Country Status (2)
Country | Link |
---|---|
JP (1) | JPWO2004088539A1 (en) |
WO (1) | WO2004088539A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5539020B2 (en) * | 2010-05-20 | 2014-07-02 | 株式会社マキタ | Cutting tool dust collector |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2715465B2 (en) * | 1988-08-31 | 1998-02-18 | 日本電気株式会社 | Symbol string matching device |
-
2003
- 2003-03-31 WO PCT/JP2003/004088 patent/WO2004088539A1/en active Application Filing
- 2003-03-31 JP JP2004570163A patent/JPWO2004088539A1/en active Pending
Also Published As
Publication number | Publication date |
---|---|
WO2004088539A1 (en) | 2004-10-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8095526B2 (en) | Efficient retrieval of variable-length character string data | |
US8078593B1 (en) | Dictionary architecture and methodology for revision-tolerant data de-duplication | |
US8972450B2 (en) | Multi-stage parallel multi-character string matching device | |
JPH07297728A (en) | Method and system for searching coincidence of patterns | |
US20030037209A1 (en) | Memory engine for the inspection and manipulation of data | |
JP2005242997A (en) | Data retrieval device and method | |
US9372887B2 (en) | Compression ratio improvement by lazy match evaluation on the string search CAM | |
US8947272B2 (en) | Decoding encoded data | |
US9419646B2 (en) | Hardware compression to find backward references with multi-level hashes | |
JP3644494B2 (en) | Information retrieval device | |
JP6613019B2 (en) | Device for searching for patterns | |
US7933885B1 (en) | Longest matching prefix search engine with hierarchical decoders | |
US9703484B2 (en) | Memory with compressed key | |
JPWO2004088539A1 (en) | Parsing method and programmable processor unit for parsing | |
JP2004334545A (en) | Filter circuit | |
US20160105363A1 (en) | Memory system for multiple clients | |
US20180032253A1 (en) | Content addressable memory system | |
WO2001071483A2 (en) | Determinaton of a minimum or maximum value in a set of data | |
JPWO2002101935A1 (en) | Decoding device, decoding method, lookup table, and decoding program | |
JP2007274051A (en) | Byte sequence searcher and searching method | |
JP2589884B2 (en) | Bit search circuit | |
CN110781100A (en) | Data detection method, logic chip and network equipment | |
JP2003296368A (en) | Device and method for retrieving database, and storage medium and program | |
JP2013149269A (en) | Retrieval device | |
JPH09180469A (en) | Associative storage |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080408 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20080609 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20080722 |
|
A711 | Notification of change in applicant |
Free format text: JAPANESE INTERMEDIATE CODE: A712 Effective date: 20080730 |