JP2008146162A - Canonical representation generation device and method and program - Google Patents
Canonical representation generation device and method and program Download PDFInfo
- Publication number
- JP2008146162A JP2008146162A JP2006329679A JP2006329679A JP2008146162A JP 2008146162 A JP2008146162 A JP 2008146162A JP 2006329679 A JP2006329679 A JP 2006329679A JP 2006329679 A JP2006329679 A JP 2006329679A JP 2008146162 A JP2008146162 A JP 2008146162A
- Authority
- JP
- Japan
- Prior art keywords
- value
- attribute
- regular expression
- range condition
- limit value
- 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
Links
- 238000000034 method Methods 0.000 title claims description 134
- 230000014509 gene expression Effects 0.000 claims description 686
- 238000012545 processing Methods 0.000 claims description 110
- 230000008569 process Effects 0.000 claims description 59
- 238000004364 calculation method Methods 0.000 claims description 32
- 238000010586 diagram Methods 0.000 description 9
- 238000006243 chemical reaction Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 7
- 238000012937 correction Methods 0.000 description 4
- 230000007717 exclusion Effects 0.000 description 4
- 238000000605 extraction Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 238000004519 manufacturing process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 210000001072 colon Anatomy 0.000 description 2
- 230000003247 decreasing effect Effects 0.000 description 2
- 230000002250 progressing effect Effects 0.000 description 2
- OHVLMTFVQDZYHP-UHFFFAOYSA-N 1-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)-2-[4-[2-[[3-(trifluoromethoxy)phenyl]methylamino]pyrimidin-5-yl]piperazin-1-yl]ethanone Chemical compound N1N=NC=2CN(CCC=21)C(CN1CCN(CC1)C=1C=NC(=NC=1)NCC1=CC(=CC=C1)OC(F)(F)F)=O OHVLMTFVQDZYHP-UHFFFAOYSA-N 0.000 description 1
- HMUNWXXNJPVALC-UHFFFAOYSA-N 1-[4-[2-(2,3-dihydro-1H-inden-2-ylamino)pyrimidin-5-yl]piperazin-1-yl]-2-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)ethanone Chemical compound C1C(CC2=CC=CC=C12)NC1=NC=C(C=N1)N1CCN(CC1)C(CN1CC2=C(CC1)NN=N2)=O HMUNWXXNJPVALC-UHFFFAOYSA-N 0.000 description 1
- VZSRBBMJRBPUNF-UHFFFAOYSA-N 2-(2,3-dihydro-1H-inden-2-ylamino)-N-[3-oxo-3-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)propyl]pyrimidine-5-carboxamide Chemical compound C1C(CC2=CC=CC=C12)NC1=NC=C(C=N1)C(=O)NCCC(N1CC2=C(CC1)NN=N2)=O VZSRBBMJRBPUNF-UHFFFAOYSA-N 0.000 description 1
- LDXJRKWFNNFDSA-UHFFFAOYSA-N 2-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)-1-[4-[2-[[3-(trifluoromethoxy)phenyl]methylamino]pyrimidin-5-yl]piperazin-1-yl]ethanone Chemical compound C1CN(CC2=NNN=C21)CC(=O)N3CCN(CC3)C4=CN=C(N=C4)NCC5=CC(=CC=C5)OC(F)(F)F LDXJRKWFNNFDSA-UHFFFAOYSA-N 0.000 description 1
- WZFUQSJFWNHZHM-UHFFFAOYSA-N 2-[4-[2-(2,3-dihydro-1H-inden-2-ylamino)pyrimidin-5-yl]piperazin-1-yl]-1-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)ethanone Chemical compound C1C(CC2=CC=CC=C12)NC1=NC=C(C=N1)N1CCN(CC1)CC(=O)N1CC2=C(CC1)NN=N2 WZFUQSJFWNHZHM-UHFFFAOYSA-N 0.000 description 1
- IHCCLXNEEPMSIO-UHFFFAOYSA-N 2-[4-[2-(2,3-dihydro-1H-inden-2-ylamino)pyrimidin-5-yl]piperidin-1-yl]-1-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)ethanone Chemical compound C1C(CC2=CC=CC=C12)NC1=NC=C(C=N1)C1CCN(CC1)CC(=O)N1CC2=C(CC1)NN=N2 IHCCLXNEEPMSIO-UHFFFAOYSA-N 0.000 description 1
- MKYBYDHXWVHEJW-UHFFFAOYSA-N N-[1-oxo-1-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)propan-2-yl]-2-[[3-(trifluoromethoxy)phenyl]methylamino]pyrimidine-5-carboxamide Chemical compound O=C(C(C)NC(=O)C=1C=NC(=NC=1)NCC1=CC(=CC=C1)OC(F)(F)F)N1CC2=C(CC1)NN=N2 MKYBYDHXWVHEJW-UHFFFAOYSA-N 0.000 description 1
- NIPNSKYNPDTRPC-UHFFFAOYSA-N N-[2-oxo-2-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)ethyl]-2-[[3-(trifluoromethoxy)phenyl]methylamino]pyrimidine-5-carboxamide Chemical compound O=C(CNC(=O)C=1C=NC(=NC=1)NCC1=CC(=CC=C1)OC(F)(F)F)N1CC2=C(CC1)NN=N2 NIPNSKYNPDTRPC-UHFFFAOYSA-N 0.000 description 1
- AFCARXCZXQIEQB-UHFFFAOYSA-N N-[3-oxo-3-(2,4,6,7-tetrahydrotriazolo[4,5-c]pyridin-5-yl)propyl]-2-[[3-(trifluoromethoxy)phenyl]methylamino]pyrimidine-5-carboxamide Chemical compound O=C(CCNC(=O)C=1C=NC(=NC=1)NCC1=CC(=CC=C1)OC(F)(F)F)N1CC2=C(CC1)NN=N2 AFCARXCZXQIEQB-UHFFFAOYSA-N 0.000 description 1
- 101100425598 Solanum lycopersicum tm-1 gene Proteins 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010606 normalization Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000000126 substance Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本発明は、正規表現生成装置及び正規表現生成方法及び正規表現生成プログラムに関するものである。本発明は、特に、正規表現を用いた検索条件生成装置、検索条件生成方式、検索条件生成プログラムに関するものである。 The present invention relates to a regular expression generation device, a regular expression generation method, and a regular expression generation program. In particular, the present invention relates to a search condition generation device, a search condition generation method, and a search condition generation program using regular expressions.
検索のために入力された検索条件(キーワード)を、異なった表記でも類似した表記でも検索可能なように正規表現に変換し、検索対象に誤字脱字が含まれている場合や改行コードが含まれている場合でも検索できるようにする技術が公知である(例えば、特許文献1参照)。 The search conditions (keywords) entered for the search are converted to regular expressions so that they can be searched with different or similar notations, and the search target includes typographical errors and line feed codes. A technique for making it possible to perform a search even in the case where the information is stored is known (for example, see Patent Document 1).
検索対象としては、例えば、ログを保存するデータベースが挙げられる。近年、ログは多様化、大規模化しており、ログを効率的に管理するためのログ専用データベース管理システムの必要性が高まっている(例えば、非特許文献1参照)。
情報セキュリティの分野を中心に、ログを収集・保存・分析する動きが進んでいる。ここでいうログには、サーバなどの情報機器の動作履歴・アクセス履歴、セキュリティ機器やソフトウェアが記録するイベントの履歴、ネットワーク上の通信履歴、電子メールの送受信履歴(メールの内容も含む)などがある。これらログの多くはテキストの情報として記録され、そのログの出力元ごとに個別に管理されてきた。情報セキュリティの分野において、これら多種多様な情報源から出力されたログを収集し、一元的に管理することにより、情報漏洩などの事件が発生した場合に、その証拠保全・原因究明などに役立てようという動きが進んでいる。 The movement of collecting, storing and analyzing logs is progressing mainly in the field of information security. The logs used here include the operation history and access history of information devices such as servers, the history of events recorded by security devices and software, the communication history on the network, and the transmission and reception history of e-mails (including the contents of e-mails). is there. Many of these logs are recorded as text information and managed individually for each output source of the logs. In the field of information security, collecting logs output from these various information sources and managing them centrally will help to preserve evidence and investigate the causes of incidents such as information leaks. The movement is progressing.
ログには次のような特徴がある。 The log has the following characteristics.
ログは、常に生成され続けるものであるため、その量も時間の経過と共に増加し続ける。また、上記のような目的で収集する場合は、数ヵ月〜数年単位という長期間保存し続ける必要があり、その量は膨大なものとなる。また、ログはその出力元ごとに出力する内容が異なり、多様な形式が存在する。形式については、日時や数値の情報を含むものが多く、自由度に差はあるものの、書式が決まっている場合が多い。ただ、その書式はログの情報源によって個別に決まっており、共通の書式があるわけではない。 Since the log is constantly generated, the amount thereof continues to increase over time. Moreover, when collecting for the above purposes, it is necessary to keep for a long period of several months to several years, and the amount becomes enormous. In addition, the log output contents differ depending on the output source, and there are various formats. Many of the formats include date and time information, and there are many differences in the degree of freedom, but the formats are often fixed. However, the format is individually determined by the log information source, and there is no common format.
そのため、従来の電子文書の検索装置においては、文書に含まれる属性情報を検索する場合には、文書から事前に属性値(属性の値のことであるが、以下では、単に「属性」という場合がある)を抽出しておいて、専用のファイルに記録して管理するものや、リレーショナルデータベース管理システムなどを利用して管理することが一般的であった。 Therefore, in a conventional electronic document search apparatus, when searching for attribute information included in a document, an attribute value (attribute value in advance) from the document is referred to as “attribute” below. It is common to use a relational database management system or the like that is extracted and recorded in a dedicated file for management.
しかし、ログには上で述べたような書式の多様性があるため、保存するログの種類を増やした場合に、事前に属性を抽出する方式では、属性の抽出方法を定義しない限り属性情報を抽出して保存することができないという課題があった。また、抽出したい属性の種類を追加する場合にも、時間の経過と共に増加し続けるログを長期間保存しているとその量が膨大なものとなるため、保存済みの全てログから属性を抽出し直すことは困難であるという課題があった。 However, because of the variety of formats described above, when the number of types of logs to be saved is increased, the attribute extraction method uses attribute information as long as the attribute extraction method is not defined. There was a problem that it could not be extracted and stored. Also, when adding the type of attribute that you want to extract, if the log that keeps increasing over time is stored for a long time, the amount will be huge, so extract the attribute from all the saved logs There was a problem that it was difficult to fix.
このようなログの保存・検索には、非特許文献1に示すようなログ専用データベースが有効である。このログ専用データベースは、以下のような方針に基づいて設計されている。
(1)ログの形式は意識せず、収集してきたログをそのままの形式で記憶媒体に保存する。
(2)ログの書式を意識した検索条件により検索する。
For such log storage and retrieval, a log-dedicated database as shown in Non-Patent
(1) Regardless of the log format, the collected logs are stored in the storage medium in the same format.
(2) Search according to search conditions that are conscious of the log format.
そうすることにより、以下のような効果がある。
(1)ログからの属性抽出などを行わないため、ありとあらゆる形式のログの保存が可能。
(2)ログの書式を意識した検索条件を正規表現により指定することにより、検索対象の属性などを柔軟に指定することが可能。
By doing so, there are the following effects.
(1) Since no attribute extraction is performed from the log, it is possible to save any type of log.
(2) By specifying the search conditions with consideration of the log format using regular expressions, it is possible to flexibly specify the attributes to be searched.
ここで、正規表現とは、文字列による検索条件の表記法の一種である。正規表現では、検索文字列の一部に、複数文字や文字列からの選択、また、それらの繰り返しの指定を許すことにより、検索条件をより一般化して表記することが可能である。 Here, the regular expression is a kind of notation of a search condition by a character string. In regular expressions, it is possible to express search conditions in a more general manner by allowing selection from a plurality of characters and character strings, and specifying repetition of them as part of a search character string.
上記のログ専用データベースでは、検索条件によってはその正規表現が複雑なものとなり、記述が困難であるという課題がある。例えば、ログの中から「2006/7/1〜2006/10/15」の範囲に含まれる日付を検索するための正規表現は、
“[^0−9](2006/([7−8]/([1−9]|[1−2][0−9]|3[0−1])|9/([1−9]|[1−2][0−9]|30)|10/([1−9]|1[0−5]))[^0−9]”
などと記述することができる。このような正規表現は、正規表現の知識の乏しい者には記述が困難であると同時に、正規表現を熟知している者にとっても正確に記述するためには試行錯誤を要するものである。
In the above-mentioned log-dedicated database, there is a problem that the regular expression becomes complicated depending on the search condition and is difficult to describe. For example, a regular expression for searching a date included in the range of “2006/7/1 to 2006/10/15” from the log is:
“[^ 0-9] (2006 / ([7-8] / ([1-9] | [1-2] [0-9] | 3 [0-1]) | 9 / ([1-9 ] | [1-2] [0-9] | 30) | 10 / ([1-9] | 1 [0-5])) [^ 0-9] "
And so on. Such regular expressions are difficult to describe for those who have little knowledge of regular expressions, and at the same time, those who are familiar with regular expressions need trial and error to write accurately.
同様に、ログの書式を意識した検索条件によっても、その正規表現の記述が困難なものがある。そのようなものの例として、CSV(Comma・Separated・Values)形式のログに対して、カンマ「,」で区切られた特定のフィールドを対象とした検索を行う場合の検索条件がある。例えば、「行の先頭から3番目と4番目のカンマに囲まれたフィールドに『ファイル』という文字列が含まれる」という検索条件は、
“(^|¥n)([^,]*,){3}[^,]*ファイル”
のように記述することができる。一口にCSV形式といっても、フィールドがさらにダブルクォーテーション「”」で囲まれているものもあるなど、様々なパターンを網羅しようとすると正規表現がさらに複雑になり、検索条件の記述が困難となる。また、特定のフィールドに上記のような特定の範囲に含まれる日付を検索するための正規表現も複雑なものとなる。
Similarly, there are some cases where it is difficult to describe the regular expression depending on the search condition in consideration of the log format. As an example of such a case, there is a search condition in a case where a search for a specific field separated by a comma “,” is performed on a log in a CSV (Comma / Separated / Values) format. For example, a search condition that “a character string“ file ”is included in the field surrounded by the third and fourth commas from the top of the line”
“(^ | ¥ n) ([^,] *,) {3} [^,] * file”
Can be described as follows. Even though it is a CSV format, some fields are surrounded by double quotes “” ”, so if you try to cover various patterns, regular expressions will become more complicated and it will be difficult to describe search conditions. Become. Further, a regular expression for searching for a date included in a specific field as described above in a specific field becomes complicated.
正規表現を利用したテキストの検索は、UNIX(登録商標)系OS(オペレーティングシステム)のgrepコマンドや、スクリプト言語Perlを始めとして広く利用されている。上記のような課題は、ログの検索に限定して存在する課題ではなく、これらの正規表現を利用した検索を行う処理系に共通して存在するものである。また、従来技術のように、キーワードを異なった表記でも類似した表記でも検索可能なように正規表現に変換する方式にも依然として存在する課題である。 Text search using regular expressions is widely used, including the grep command of the UNIX (registered trademark) OS (operating system) and the script language Perl. The problems as described above are not problems that are limited to log searches, but are common to processing systems that perform searches using these regular expressions. Further, as in the prior art, there is still a problem that exists in a method of converting a keyword into a regular expression so that the keyword can be searched with different notation or similar notation.
本発明は、一定の範囲の属性値を検索するための正規表現を効率的に生成することを目的とする。 An object of the present invention is to efficiently generate a regular expression for searching a certain range of attribute values.
本発明の一の態様に係る正規表現生成装置は、
属性値の下限値と上限値と書式とを示す属性範囲条件データを入力装置から入力する属性範囲条件入力部と、
前記属性範囲条件入力部により入力された属性範囲条件データが示す書式に基づいて、前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値以上の属性値であって、最下位桁から少なくとも1桁が当該桁の最大値である第1の値と、前記属性範囲条件入力部により入力された属性範囲条件データが示す上限値以下の属性値であって、最下位桁から少なくとも1桁が当該桁の最小値である第2の値とを、処理装置で演算する演算部と、
前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値と上限値と、前記演算部により演算された第1の値と第2の値とを、記憶装置に記憶する属性値記憶部と、
前記属性値記憶部により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データと、前記属性値記憶部により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データとを、処理装置で生成するとともに、前記属性値記憶部により記憶された第1の値と第2の値との間に属性値が存在する場合には当該属性値を正規表現で表す中位領域データを処理装置で生成する正規表現生成部と、
前記正規表現生成部により生成された下位領域データと上位領域データと中位領域データとを処理装置で結合して、前記属性値記憶部により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データを生成する正規表現結合部とを備えることを特徴とする。
A regular expression generation device according to one aspect of the present invention is provided.
An attribute range condition input unit for inputting attribute range condition data indicating a lower limit value, an upper limit value and a format of the attribute value from an input device;
Based on the format indicated by the attribute range condition data input by the attribute range condition input unit, the attribute value is equal to or greater than the lower limit value indicated by the attribute range condition data input by the attribute range condition input unit, and the least significant digit A first value in which at least one digit is the maximum value of the digit and an attribute value equal to or lower than the upper limit value indicated by the attribute range condition data input by the attribute range condition input unit, and at least 1 from the lowest digit A computing unit that computes the second value, the digit of which is the minimum value of the digit, by the processing device;
Attribute value storage that stores the lower limit value and the upper limit value indicated by the attribute range condition data input by the attribute range condition input unit, and the first value and the second value calculated by the calculation unit in a storage device And
Lower region data representing the attribute value from the lower limit value to the first value stored by the attribute value storage unit in a regular expression, and the attribute value from the second value to the upper limit value stored by the attribute value storage unit If the attribute value exists between the first value and the second value stored in the attribute value storage unit, the upper region data representing the regular expression in the regular expression is generated by the processing device. A regular expression generating unit that generates intermediate region data representing a value in a regular expression by a processing device;
The lower region data, the upper region data, and the middle region data generated by the regular expression generation unit are combined by a processing device, and the attribute values from the lower limit value to the upper limit value stored by the attribute value storage unit are normalized. And a regular expression combining unit that generates regular expression data expressed in terms of expressions.
本発明の一の態様によれば、正規表現生成装置において、演算部が属性値の書式に基づいて、下限値以上の属性値であって最下位桁から少なくとも1桁が当該桁の最大値である第1の値と上限値以下の属性値であって最下位桁から少なくとも1桁が当該桁の最小値である第2の値とを演算し、正規表現生成部が下限値から第1の値までの属性値を正規表現で表す下位領域データと第2の値から上限値までの属性値を正規表現で表す上位領域データとを生成するとともに、第1の値と第2の値との間に属性値が存在する場合には当該属性値を正規表現で表す中位領域データを生成し、正規表現結合部が下位領域データと上位領域データと中位領域データとを結合することにより、一定の範囲の属性値を検索するための正規表現を効率的に生成することが可能となる。 According to one aspect of the present invention, in the regular expression generation device, the arithmetic unit is an attribute value that is equal to or greater than the lower limit value based on the format of the attribute value, and at least one digit from the least significant digit is the maximum value of the digit. A certain first value and an attribute value equal to or lower than the upper limit value, and at least one digit from the least significant digit is calculated as a second value that is the minimum value of the digit, and the regular expression generator generates the first value from the lower limit value. Generating lower region data that represents an attribute value up to the value in a regular expression and upper region data representing an attribute value from the second value to the upper limit value in a regular expression, and the first value and the second value When there is an attribute value in between, the middle region data that represents the attribute value in regular expression is generated, and the regular expression combining unit combines the lower region data, the upper region data, and the middle region data, Efficiently generate regular expressions for searching a range of attribute values It becomes possible.
以下、本発明の実施の形態について、図を用いて説明する。 Hereinafter, embodiments of the present invention will be described with reference to the drawings.
以下では、正規表現として、特に明示していない限り、一般的に普及しているものを想定して説明する。一般的な正規表現においては、例えば、
(1)<通常の文字>は、通常の文字を照合する。
(2)¥<特殊文字>は、特殊文字(「|」、「?」、「*」、「+」「¥」、「^」など)を照合する。
(3)[abc...]は、文字abc...中の任意の1文字を照合する。
(4)[a−z]は、文字コードがaからzまでの範囲にある任意の1文字を照合する。
(5)[^abc...]は、文字abc...以外の任意の1文字を照合する。
(6)[^a−z]は、文字コードがaからzまでの範囲にはない任意の1文字を照合する。
(7)^は、行の先頭を照合する。
(8)$は、行の末尾を照合する。
(9)<正規表現>?は、<正規表現>が0回又は1回現れるものを照合する。
(10)<正規表現>*は、<正規表現>が0回又は任意の回数繰り返されるものを照合する。
(11)<正規表現>+は、<正規表現>が1回以上繰り返されるものを照合する。
(12)<正規表現>{n}は、<正規表現>がn回繰り返されるものを照合する。
(13)<正規表現>{n,}は、<正規表現>がn回以上繰り返されるものを照合する。
(14)<正規表現>{,m}は、<正規表現>が0回以上m回以下繰り返されるものを照合する。
(15)<正規表現>{n,m}は、<正規表現>がn回以上m回以下繰り返されるものを照合する。
(16)<正規表現1>|<正規表現2>は、<正規表現1>又は<正規表現2>を照合する。
(17)<正規表現1><正規表現2>は、前半部分が<正規表現1>で後半部分が<正規表現2>であるものを照合する。
In the following description, a regular expression is assumed assuming that it is generally used unless otherwise specified. In general regular expressions, for example,
(1) <ordinary character> collates ordinary characters.
(2) \ <special character> collates special characters (“|”, “?”, “*”, “+”, “¥”, “^”, etc.).
(3) [abc. . . ] Is the character abc. . . Match any single character in it.
(4) [az] collates an arbitrary character whose character code is in the range from a to z.
(5) [^ abc. . . ] Is the character abc. . . Match any single character other than.
(6) [^ a-z] collates an arbitrary character whose character code is not in the range from a to z.
(7) ^ matches the beginning of a line.
(8) $ matches the end of the line.
(9) <Regular expression>? Matches what <regular expression> appears 0 times or once.
(10) <Regular expression> * matches what <Regular expression> is repeated 0 times or any number of times.
(11) <Regular expression> + matches those in which <Regular expression> is repeated one or more times.
(12) <Regular expression> {n} is a collation of <regular expression> repeated n times.
(13) <Regular expression> {n,} matches those in which <regular expression> is repeated n times or more.
(14) <Regular expression> {, m} matches those in which <regular expression> is repeated 0 to m times.
(15) <Regular expression> {n, m} matches those in which <regular expression> is repeated n times or more and m times or less.
(16) <
(17) <
以下では、原則として、正規表現はダブルクォーテーションで囲って“<正規表現>”という形式で示すものとする。 In the following, as a general rule, regular expressions are shown in the form of “<regular expression>” enclosed in double quotations.
実施の形態1.
図1は、本実施の形態に係る正規表現生成装置100の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of a regular
図1において、正規表現生成装置100は、属性範囲条件入力部101、演算部102、属性値記憶部103、正規表現生成部104、正規表現結合部105、出力部106を備える。また、正規表現生成装置100は、記憶装置151、処理装置152、入力装置153、出力装置154などのハードウェア装置を備える(又はこれらのハードウェア装置が正規表現生成装置100に接続される)。ハードウェア装置は正規表現生成装置100の各部によって利用される。例えば、処理装置152は、正規表現生成装置100の各部でデータや情報の演算、加工、読み取り、書き込みなどを行うために利用される。記憶装置151は、そのデータや情報を記憶するために利用される。また、入力装置153は、そのデータや情報を入力するために、出力装置154は、そのデータや情報を出力するために利用される。
In FIG. 1, the regular
属性範囲条件入力部101は、属性範囲条件データを入力装置153から入力する。属性範囲条件データは、属性値の下限値と上限値と書式とを示す属性範囲条件のデータである。例えば、属性値を123〜7654の範囲の整数値とした場合、下限値は123、上限値は7654、書式は3〜4桁(最大4桁)の整数値型となる。この例では、属性範囲条件入力部101は、属性値の書式として、属性値が数値であることを示す属性範囲条件データを入力することとなるが、例えば、属性値が文字列であれば、属性範囲条件入力部101は、属性値の書式として、属性値が文字列であることを示す属性範囲条件データを入力することとなる。
The attribute range
演算部102は、属性範囲条件入力部101により入力された属性範囲条件データが示す書式に基づいて、第1の値と第2の値とを処理装置152で演算する。第1の値は、属性範囲条件入力部101により入力された属性範囲条件データが示す下限値以上の属性値であって、最下位桁から少なくとも1桁が当該桁の最大値である属性値である。上記の例のように、下限値を123とした場合、第1の値は129、199、999、6999、7599、7649などとなる。一方、第2の値は、属性範囲条件入力部101により入力された属性範囲条件データが示す上限値以下の属性値であって、最下位桁から少なくとも1桁が当該桁の最小値である属性値である。上記の例のように、上限値を7654とした場合、第2の値は130、200、1000、7000、7600、7650などとなる。
The
特に本実施の形態では、演算部102は、第1の値として、属性範囲条件入力部101により入力された属性範囲条件データが示す下限値と桁数が同じで少なくとも最上位桁以外の桁が各桁の最大値である属性値を演算する。上記の例のように、下限値を123とした場合、第1の値は199、999などとなる。また、演算部102は、第2の値として、属性範囲条件入力部101により入力された属性範囲条件データが示す上限値と桁数が同じで少なくとも最上位桁以外の桁が各桁の最小値である属性値を演算する。上記の例のように、上限値を7654とした場合、第2の値は1000、7000などとなる。
In particular, in the present embodiment, the
さらに本実施の形態では、演算部102は、第1の値として、属性範囲条件入力部101により入力された属性範囲条件データが示す下限値と最上位桁が同じ値でそれ以外の桁が各桁の最大値である属性値を演算する。上記の例のように、下限値を123とした場合、第1の値は199となる。また、演算部102は、第2の値として、属性範囲条件入力部101により入力された属性範囲条件データが示す上限値と最上位桁が同じ値でそれ以外の桁が各桁の最小値である属性値を演算する。上記の例のように、上限値を7654とした場合、第2の値は7000となる。
Furthermore, in the present embodiment, the
属性値記憶部103は、属性範囲条件入力部101により入力された属性範囲条件データが示す下限値と上限値と、演算部102により演算された第1の値と第2の値とを、記憶装置151に記憶する。
The attribute
正規表現生成部104は、属性値記憶部103により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データ(以下、単に「正規表現」、又は「下位領域の正規表現」などという場合がある)と、属性値記憶部103により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データ(以下、単に「正規表現」、又は「上位領域の正規表現」などという場合がある)とを、処理装置152で生成する。上記の例のように、下限値が123、上限値が7654、第1の値が199、第2の値が7000となる場合、下位領域データは、
“12[3−9]|1[3−9][0−9]”(123〜199の正規表現)、
上位領域データは、
“7[0−5][0−9][0−9]|76[0−4][0−9]|765[0−4]”(7000〜7654の正規表現)
などとなる。また、正規表現生成部104は、属性値記憶部103により記憶された第1の値と第2の値との間に属性値が存在する場合には、当該属性値を正規表現で表す中位領域データ(以下、単に「正規表現」、又は「中位領域の正規表現」などという場合がある)を処理装置152で生成する。上記の例のように、第1の値が199、第2の値が7000となる場合、中位領域データは、
“[2−9][0−9][0−9]|[1−6][0−9][0−9][0−9]”(200〜6999の正規表現)
などとなる。
The regular
“12 [3-9] | 1 [3-9] [0-9]” (regular expression of 123-199),
The upper area data is
“7 [0-5] [0-9] [0-9] | 76 [0-4] [0-9] | 765 [0-4]” (regular expression of 7000-7654)
And so on. In addition, when there is an attribute value between the first value and the second value stored in the attribute
“[2-9] [0-9] [0-9] | [1-6] [0-9] [0-9] [0-9]” (regular expression of 200 to 6999)
And so on.
正規表現結合部105は、正規表現生成部104により生成された下位領域データと上位領域データと中位領域データとを処理装置152で結合して、属性値記憶部103により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データ(以下、単に「正規表現」、又は「属性値の正規表現」という場合がある)を生成する。上記の例のように、下位領域データが“12[3−9]|1[3−9][0−9]”、上位領域データが“7[0−5][0−9][0−9]|76[0−4][0−9]|765[0−4]”、中位領域データが“[2−9][0−9][0−9]|[1−6][0−9][0−9][0−9]”となる場合、正規表現データは、
“(12[3−9]|1[3−9][0−9])|([2−9][0−9][0−9]|[1−6][0−9][0−9][0−9])|(7[0−5][0−9][0−9]|76[0−4][0−9]|765[0−4])”
などとなる。
The regular
“(12 [3-9] | 1 [3-9] [0-9]) | ([2-9] [0-9] [0-9] | [1-6] [0-9] [ 0-9] [0-9]) | (7 [0-5] [0-9] [0-9] | 76 [0-4] [0-9] | 765 [0-4]) "
And so on.
出力部106は、正規表現結合部105により生成された正規表現データを出力装置154に出力する。
The
このように、本実施の形態において、正規表現生成装置100は、検索条件として属性値の値域に含まれる値の下限値と上限値とを指定する属性範囲条件を入力とし、これを、属性範囲条件に指定された範囲に含まれる属性値を表現する文字列を照合するための正規表現に変換する検索条件生成方式、又は、この方式を計算機上で実行するための検索条件生成プログラムを実装するものである。
As described above, in the present embodiment, the regular
上記検索条件生成方式では、例えば、数値の範囲を選択する属性範囲条件を正規表現に変換する。また、例えば、文字列の範囲を選択する属性範囲条件を正規表現に変換する。 In the search condition generation method, for example, an attribute range condition for selecting a numerical range is converted into a regular expression. Also, for example, an attribute range condition for selecting a character string range is converted into a regular expression.
上記検索条件生成方式では、例えば、属性の下限値、上限値、属性の書式(属性のデータ型を含む)からなる属性範囲条件を、
属性範囲条件=(0,255,%3d)
と表記して入力する。ここでは、一例として、
属性の下限値=0
属性の上限値=255
属性の書式(桁数とデータ型)=「(最大)3桁の整数値」
としている。この例では、属性の書式を表すのに、C言語におけるprintfなどの書式付き出力関数の書式指定の表記法を流用しているが、同等の条件を指定することが可能であれば、同じ表記法である必要はない。また、同様の条件を入力することができるのであれば、その入力方法は問わない。
In the search condition generation method, for example, an attribute range condition including an attribute lower limit value, upper limit value, and attribute format (including attribute data type)
Attribute range condition = (0,255,% 3d)
And enter. Here, as an example
Lower limit of attribute = 0
Upper limit of attribute = 255
Attribute format (number of digits and data type) = "(maximum) 3-digit integer value"
It is said. In this example, the notation of format specification of a formatted output function such as “printf” in C language is used to represent the format of the attribute. It doesn't have to be law. Moreover, if the same conditions can be input, the input method is not ask | required.
上記の属性範囲条件を入力した場合、正規表現生成装置100により、その下限値から上限値までの範囲に含まれる属性値を表現する文字列を照合するための正規表現が、
正規表現=“[^0−9]([0−9]|[1−9][0−9]|1[0−9][0−9]|2[0−4][0−9]|25[0−5])[^0−9]”
などとして出力される。なお、上記の属性範囲条件を構成する項目のうち、全てが揃っている必要はない。例えば、下限値がなければ、下限値を属性値のとりうる値の最小値として扱ってもよい(上記の例では、下限値=0となる)。また、例えば、上限値がなければ、上限値を属性値のとりうる値の最大値として扱ってもよい(上記の例では、上限値=∞となる)。また、例えば、属性の書式が整数値であることが示されていなければ、属性のデータ型が文字列であると推定してもよいし、下限値と上限値が整数値であることから属性のデータ型が整数値であると推定してもよい。
When the above attribute range condition is input, a regular expression for collating a character string representing an attribute value included in the range from the lower limit value to the upper limit value by the regular
Regular expression = “[^ 0-9] ([0-9] | [1-9] [0-9] | 1 [0-9] [0-9] | 2 [0-4] [0-9 ] [25 [0-5]) [^ 0-9] "
Etc. are output. It should be noted that it is not necessary that all the items constituting the attribute range condition are complete. For example, if there is no lower limit value, the lower limit value may be handled as the minimum value that the attribute value can take (in the above example, the lower limit value = 0). For example, if there is no upper limit value, the upper limit value may be treated as the maximum value that can be taken by the attribute value (in the above example, the upper limit value is ∞). Also, for example, if the attribute format is not shown to be an integer value, the attribute data type may be assumed to be a character string, and the lower limit value and the upper limit value are integer values. It may be estimated that the data type of is an integer value.
上記検索条件生成方式は、以下でも述べるように、例えば、PC(パーソナルコンピュータ)やPCサーバなどの計算機上で動作するプログラムとして実現してもよいし、本方式を実装した機能部を備えたハードウェアとして実装してもよい。 As described below, the search condition generation method may be realized as a program that runs on a computer such as a PC (personal computer) or a PC server, or a hardware having a functional unit that implements the method. It may be implemented as wear.
図2は、正規表現生成装置100の外観の一例を示す図である。
FIG. 2 is a diagram illustrating an example of the appearance of the regular
図2において、正規表現生成装置100は、システムユニット910、CRT(Cathode・Ray・Tube)やLCD(液晶ディスプレイ)の表示画面を有する表示装置901、キーボード902(K/B)、マウス903、FDD904(Flexible・Disk・Drive)、CDD905(Compact・Disc・Drive)、プリンタ装置906などのハードウェア資源を備え、これらはケーブルや信号線で接続されている。システムユニット910は、コンピュータであり、LAN942(ローカルエリアネットワーク)、ゲートウェイ941を介してインターネット940に接続されている。
In FIG. 2, a regular
図3は、正規表現生成装置100のハードウェア資源の一例を示す図である。
FIG. 3 is a diagram illustrating an example of hardware resources of the regular
図3において、正規表現生成装置100は、プログラムを実行するCPU911(Central・Processing・Unit)(「演算装置」、「マイクロプロセッサ」、「マイクロコンピュータ」、「プロセッサ」ともいう)を備えている。CPU911は、処理装置152の一例である。CPU911は、バス912を介してROM913(Read・Only・Memory)、RAM914(Random・Access・Memory)、通信ボード915、表示装置901、キーボード902、マウス903、FDD904、CDD905、プリンタ装置906、磁気ディスク装置920と接続され、これらのハードウェアデバイスを制御する。磁気ディスク装置920の代わりに、光ディスク装置、メモリカードリーダライタなどの記憶媒体が用いられてもよい。
In FIG. 3, the regular
RAM914は、揮発性メモリの一例である。ROM913、FDD904、CDD905、磁気ディスク装置920の記憶媒体は、不揮発性メモリの一例である。これらは、記憶装置151の一例である。通信ボード915、キーボード902、マウス903、FDD904、CDD905などは、入力装置153の一例である。また、通信ボード915、表示装置901、プリンタ装置906などは、出力装置154の一例である。
The
通信ボード915は、LAN942などに接続されている。通信ボード915は、LAN942に限らず、インターネット940、あるいは、IP−VPN(Internet・Protocol・Virtual・Private・Network)、広域LAN、ATM(Asynchronous・Transfer・Mode)ネットワークなどのWAN(ワイドエリアネットワーク)などに接続されていても構わない。インターネット940あるいはWANなどに接続されている場合、ゲートウェイ941は不要となる。
The
磁気ディスク装置920には、オペレーティングシステム921、ウィンドウシステム922、プログラム群923、ファイル群924が記憶されている。プログラム群923のプログラムは、CPU911、オペレーティングシステム921、ウィンドウシステム922により実行される。プログラム群923には、本実施の形態の説明において「〜部」、「〜手段」として説明する機能を実行するプログラムが記憶されている。プログラムは、CPU911により読み出され実行される。また、ファイル群924には、本実施の形態の説明において、「〜データ」、「〜情報」、「〜ID(IDentifier)」、「〜フラグ」、「〜結果」として説明するデータや情報や信号値や変数値やパラメータが、「〜ファイル」や「〜データベース」や「〜テーブル」の各項目として記憶されている。「〜ファイル」や「〜データベース」や「〜テーブル」は、ディスクやメモリなどの記憶媒体に記憶される。ディスクやメモリなどの記憶媒体に記憶されたデータや情報や信号値や変数値やパラメータは、読み書き回路を介してCPU911によりメインメモリやキャッシュメモリに読み出され、抽出・検索・参照・比較・演算・計算・制御・出力・印刷・表示などのCPU911の処理(動作)に用いられる。抽出・検索・参照・比較・演算・計算・制御・出力・印刷・表示などのCPU911の処理中、データや情報や信号値や変数値やパラメータは、メインメモリやキャッシュメモリやバッファメモリに一時的に記憶される。
The
また、本実施の形態の説明において説明するブロック図やフローチャートの矢印の部分は主としてデータや信号の入出力を示し、データや信号は、RAM914などのメモリ、FDD904のフレキシブルディスク(FD)、CDD905のコンパクトディスク(CD)、磁気ディスク装置920の磁気ディスク、その他光ディスク、ミニディスク(MD)、DVD(Digital・Versatile・Disc)などの記録媒体に記録される。また、データや信号は、バス912や信号線やケーブルその他の伝送媒体により伝送される。
In the block diagrams and flowcharts described in the description of this embodiment, the arrows indicate mainly input and output of data and signals. Data and signals are stored in a memory such as a
また、本実施の形態の説明において「〜部」、「〜手段」として説明するものは、「〜回路」、「〜装置」、「〜機器」であってもよく、また、「〜ステップ」、「〜工程」、「〜手順」、「〜処理」であってもよい。即ち、「〜部」、「〜手段」として説明するものは、ROM913に記憶されたファームウェアで実現されていても構わない。あるいは、ソフトウェアのみ、あるいは、素子・デバイス・基板・配線などのハードウェアのみ、あるいは、ソフトウェアとハードウェアとの組み合わせ、さらには、ファームウェアとの組み合わせで実現されていても構わない。ファームウェアとソフトウェアは、プログラムとして、磁気ディスク、フレキシブルディスク、光ディスク、コンパクトディスク、ミニディスク、DVDなどの記録媒体に記憶される。このプログラムはCPU911により読み出され、CPU911により実行される。即ち、プログラムは、本実施の形態の説明で述べる「〜部」、「〜手段」としてコンピュータを機能させるものである。あるいは、本実施の形態の説明で述べる「〜部」、「〜手段」の手順や方法をコンピュータに実行させるものである。
In the description of the present embodiment, what is described as “to part” and “to means” may be “to circuit”, “to device”, and “to device”, and “to step”. , “˜step”, “˜procedure”, and “˜treatment”. That is, what is described as “˜unit” and “˜means” may be realized by firmware stored in the
以下では、説明をより具体的にするため、正規表現生成装置100が図2、図3に例示したコンピュータとハードウェア資源により実現されているものとする。
In the following, in order to make the description more specific, it is assumed that the regular
図4は、本実施の形態に係る正規表現生成方法を示すフローチャートである。図4のフローチャートに示すフローは、正規表現生成装置100を実現するコンピュータ上で実行されるプログラム(正規表現生成プログラム)の処理手順に相当する。この処理手順において、正規表現生成プログラムは、以下に示す各処理をコンピュータに実行させる。
FIG. 4 is a flowchart showing a regular expression generation method according to this embodiment. The flow shown in the flowchart of FIG. 4 corresponds to a processing procedure of a program (regular expression generation program) executed on a computer that implements the regular
正規表現生成装置100の利用者がキーボード902やマウス903で属性範囲条件データを指定すると、属性範囲条件入力部101は、その属性範囲条件データをキーボード902やマウス903から入力する(ステップS101:属性範囲条件入力処理)。
When the user of the regular
演算部102は、属性範囲条件入力部101により入力された属性範囲条件データが示す書式に基づいて、第1の値と第2の値とをCPU911で演算する(ステップS102の一部:演算処理)。属性値記憶部103は、属性範囲条件入力部101により入力された属性範囲条件データが示す下限値と上限値と、演算部102により演算された第1の値と第2の値とを、RAM914に記憶する(ステップS102の一部:属性値記憶処理)。
The
ステップS102において、演算部102は、第1の値と第2の値とを演算することにより、属性範囲条件の下限値から上限値までの範囲に含まれる属性値を、下位、中位、上位の3領域に分割している。3領域のうち、中位領域は、その範囲に含まれる属性値を半固定的に正規表現に変換可能な値の範囲である。下位領域は、属性範囲条件の下限値(即ち、属性値の下限値)から中位領域の下限値の1つ下(即ち、第1の値)までの値の範囲のことを指す。上位領域は、中位領域の上限値の1つ上(即ち、第2の値)から属性範囲条件の上限値(即ち、属性値の上限値)までの値の範囲のことを指す。各領域の算出の方法は、後で具体例を交えて説明する。
In step S102, the
正規表現生成部104は、属性値記憶部103により記憶された第1の値と第2の値との間に属性値が存在する場合には、当該属性値を正規表現で表す中位領域データをCPU911で生成する(ステップS103:正規表現生成処理の一部)。第1の値と第2の値との間に属性値が存在しない場合には、中位領域データは生成されない。正規表現生成部104は、属性値記憶部103により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データをCPU911で生成する(ステップS104:正規表現生成処理の一部)。正規表現生成部104は、属性値記憶部103により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データをCPU911で生成する(ステップS105:正規表現生成処理の一部)。
When there is an attribute value between the first value and the second value stored in the attribute
ステップS103、S104、S105において、正規表現生成部104は、中位、下位、上位の3領域のそれぞれについて、個別に対応する正規表現を生成している。ステップS103、S104、S105の処理は順序に依存しないため、任意の順序で実行してよい。
In steps S103, S104, and S105, the regular
正規表現結合部105は、正規表現生成部104により生成された下位領域データと上位領域データと中位領域データとをCPU911で結合して(ステップS103で中位領域データが生成されなかった場合には、下位領域データと上位領域データのみを結合することになる)、属性値記憶部103により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データを生成する(ステップS106:正規表現結合処理)。
The regular
出力部106は、正規表現結合部105により生成された正規表現データを表示装置901の画面などに出力する(ステップS107:出力処理)。正規表現生成装置100の利用者は、この正規表現データを検索条件として、前述したログ専用データベースなどに入力することにより、ログなどの検索を容易に行うことができる。
The
以下、正規表現を生成する処理の流れを、例を交えて説明する。ここで説明するのは、属性範囲条件の下限値Aと上限値Bに対して、A≦X≦Bを満たす値X(下限値Aから上限値Bまでの属性値X)を表現する文字列を照合するための正規表現を生成する処理の流れである。 Hereinafter, the flow of processing for generating a regular expression will be described with an example. What is described here is a character string expressing a value X (attribute value X from lower limit value A to upper limit value B) that satisfies A ≦ X ≦ B with respect to lower limit value A and upper limit value B of the attribute range condition. This is a flow of processing for generating a regular expression for matching.
初めにここでは属性値の下限値と上限値の桁数が等しい場合に限定して、次のように表すものとする。
下限値A:AnAn−1...A2A1
上限値B:BnBn−1...B2B1
ここで、添え字が大きいほど上位の桁とする。
属性値を構成する属性要素Ai、Bi(1≦i≦n)は、それぞれ1個の数字や文字で、その値域をv1≦Ai、Bi≦vqとする。ただし、最上位桁のみv2≦An、Bn≦vqとする。ここでは簡単のために、最上位桁を除く全ての桁の値域は同じであるとする。また、(vj)kで「k桁目の値がvj」であることを表すものとする。さらに、この属性値の大小関係は以下の基準で決定されるものとする。
An=Bn,An−1=Bn−1,...,Ak+1=Bk+1(1≦k≦n)のとき、Bk>AkならばB>A
Ai+1と記述してAiの値を1大きくすることとし、Ai=vjの場合Ai+1=vj+1とする。ただし、Ai=vqの場合はAi+1=v1とし、さらにAi+1+1とする。同様に、Ai−1と記述してAiの値を1小さくすることとし、Ai=vjの場合Ai−1=vj−1とする。ただし、Ai=v1の場合はAi−1=vqとし、さらにAi+1−1とする。属性値Aを1大きくすることをA+1と記述し、A1+1を意味するものとする。同様に、属性値Aを1小さくすることをA−1と記述し、A1−1を意味するものとする。
First, here, it is expressed as follows only when the lower limit value of the attribute value is equal to the number of digits of the upper limit value.
Lower limit A: A n A n-1 . . . A 2 A 1
Upper limit B: B n B n−1 . . . B 2 B 1
Here, the larger the subscript, the higher the digit.
Each of the attribute elements A i and B i (1 ≦ i ≦ n) constituting the attribute value is one number or character, and the value ranges are v 1 ≦ A i and B i ≦ v q . However, it is assumed that only the most significant digit is v 2 ≦ A n and B n ≦ v q . Here, for simplicity, it is assumed that the value ranges of all the digits except the most significant digit are the same. Further, (v j ) k represents that “the value of the k-th digit is v j ”. Furthermore, the magnitude relationship between the attribute values is determined based on the following criteria.
A n = B n , A n−1 = B n−1,. . . , A k + 1 = B k + 1 (1 ≦ k ≦ n), B> A if B k > A k
A i +1 is described to increase the value of A i by 1. When A i = v j , A i + 1 = v j + 1 . However, when A i = v q , A i + 1 = v 1 and further A i + 1 +1. Similarly, A i −1 is described, and the value of A i is decreased by 1. When A i = v j , A i −1 = v j−1 . However, when A i = v 1 , A i −1 = v q, and further A i + 1 −1. Increasing the attribute value A by 1 is described as A + 1, and means A 1 +1. Similarly, reducing the attribute value A by 1 is described as A-1, and means A 1 -1.
このような特徴を持つ属性値として代表的なものに、整数値(絶対値)がある。 A typical attribute value having such characteristics is an integer value (absolute value).
ここで、下限値Aと上限値Bが等しい場合は、ステップS102を実行するまでもなく正規表現として以下を出力するだけでよい。
正規表現:“AnAn−1...A2A1”
Here, when the lower limit value A and the upper limit value B are equal, it is only necessary to output the following as a regular expression without executing step S102.
Regular expression: “A n A n−1 ... A 2 A 1 ”
以降は、下限値と上限値が等しくない場合について説明する。 Hereinafter, a case where the lower limit value and the upper limit value are not equal will be described.
ステップS102では、演算部102は、属性値を下位、中位、上位の3領域に分割するが、その中でも最初に中位領域を求める。中位領域は、図5に示した処理の流れに従って、以下のように値域を求めることができる。図5では中位領域の下限値(即ち、第1の値より1大きい値)をL、上限値をU(即ち、第2の値より1小さい値)としている。
In step S102, the
図5において、演算部102は、最上位桁(n桁目)から順番に(ステップS201)属性値の下限値Aと上限値Bの同じ桁の値をCPU911により比較していく(ステップS202)。ある桁(i桁目)について、AとBとで値が同じ場合、演算部102は、LとUの同じ桁(Li、Ui)もその値(Ai)に設定し(ステップS203)、次の桁について(ステップS204)AとBを比較する。比較した桁について、AとBとで値が異なる場合、演算部102は、Lの同じ桁(Li)をAの値より1大きい値(Ai+1)に設定するとともに、Uの同じ桁(Ui)をBの値より1小さい値(Bi−1)に設定する(ステップS205)。そして、次の桁から最下位桁までの各桁について(ステップS206、S207)、Lをその桁の最小値(v1)に設定するとともに、Uをその桁の最大値(vq)に設定する(ステップS208)。その結果、下記の通りLとUが得られる。このとき、属性値記憶部103はLとUをRAM914に記憶している。
中位領域(下限値L):An...Ak+1(Ak+1)(v1)k−1...(v1)1
中位領域(上限値U):Bn...Bk+1(Bk−1)(vq)k−1...(vq)1
ただし、An=Bn,An−1=Bn−1,...,Ak+1=Bk+1(1≦k≦n)
In FIG. 5, the
Middle region (lower limit L): An . . . A k + 1 (A k +1) (v 1 ) k−1 . . . (V 1 ) 1
Middle region (upper limit U): B n . . . B k + 1 (B k −1) (v q ) k−1 . . . (V q ) 1
However, A n = B n , A n−1 = B n−1,. . . , A k + 1 = B k + 1 (1 ≦ k ≦ n)
次に、中位領域の下限値を1小さくした値を下位領域の上限値(即ち、第1の値)とし、下位領域は以下のように求める。このとき、属性値記憶部103は属性値の下限値Aと第1の値(L−1)をRAM914に記憶している。
下位領域(下限値A):AnAn−1...A2A1
下位領域(上限値):An...Ak(vq)k−1...(vq)1
Next, a value obtained by reducing the lower limit value of the middle region by 1 is set as the upper limit value (that is, the first value) of the lower region, and the lower region is obtained as follows. At this time, the attribute
Lower region (lower limit A): An n n-1 . . . A 2 A 1
Lower region (upper limit value): An . . . A k (v q ) k−1 . . . (V q ) 1
また、中位領域の上限値を1大きくした値を上位領域の下限値(即ち、第2の値)とし、上位領域は以下のように求める。このとき、属性値記憶部103は第2の値(U+1)と属性値の上限値BをRAM914に記憶している。
上位領域(下限値):Bn...Bk(v1)k−1...(v1)1
上位領域(上限値B):BnBn−1...B2B1
Further, the value obtained by increasing the upper limit value of the middle region by 1 is set as the lower limit value (ie, the second value) of the upper region, and the upper region is obtained as follows. At this time, the attribute
Upper region (lower limit): B n . . . B k (v 1 ) k−1 . . . (V 1 ) 1
Upper region (upper limit B): B n B n−1 . . . B 2 B 1
ステップS103において、正規表現生成部104は、中位領域の正規表現を生成する。中位領域に対応する正規表現は、中位領域の非共通部分の桁数kとAk、Bkの値にのみ依存し、以下の通り生成することができる。k+1桁目からn桁目までの値は、ステップS106において、共通部分として処理できるため、ここでは省略している。
中位領域の正規表現:“[(Ak+1)−(Bk−1)][v1−vq]{k−1}”
ここで、Bk−Ak=1の場合、(Ak+1)>(Bk−1)となるが、この場合は中位領域の正規表現を出力しないものとする。それ以外は同様に処理することができる。
In step S103, the regular
Regular expression of middle region: “[(A k +1) − (B k −1)] [v 1 −v q ] {k−1}”
Here, when B k −A k = 1, (A k +1)> (B k −1) is satisfied. In this case, the regular expression of the middle region is not output. Other than that, it can process similarly.
なお、上記正規表現において、k−1=1であれば末尾の“{1}”を省略してもよい。また、k−1=0であれば末尾の“[v1−vq]{0}”を省略してもよい。以降の説明においても、正規表現中の“[vi−vj]{1}”は“[vi−vj]”と記述できるものとし、“[vi−vj]{0}”は省略できるものとする。また、“[vi−vi]”は単に“vi”と記述できるものとする。 In the regular expression, if “k−1 = 1”, “{1}” at the end may be omitted. If k−1 = 0, the end “[v 1 −v q ] {0}” may be omitted. Also in the following description, “[v i −v j ] {1}” in the regular expression can be described as “[v i −v j ]”, and “[v i −v j ] {0}”. Can be omitted. Also, "[v i -v i] " is simply assumed to be described as "v i".
図6は、以下のような属性値の範囲に対応する正規表現の生成処理の流れを示す。
下限値:AkAk−1...A1
上限値:(vj)k(vq)k−1...(vq)1(ただし、vj≧Ak)
FIG. 6 shows the flow of regular expression generation processing corresponding to the following attribute value ranges.
Lower limit: A k A k−1 . . . A 1
Upper limit value: (v j ) k (v q ) k−1 . . . (V q ) 1 (where v j ≧ A k )
図6の処理の流れでは、正規表現生成部104は、最下位の桁から上位の桁に向かって処理を進めている。ここでの入力は、下限値Ak...A1、上限値(vj)k(vq)k−1...(vq)1、及び桁数kである。ステップS301において、正規表現生成部104は、RAM914内の正規表現の格納領域(E)に初期値として“Ak...A2[A1−vq]”をセットする。ステップS302以降では、下位2桁目から始めてk−1桁目までステップS304〜S306の処理を繰り返す。ステップS303において、処理の対象がk桁目より下位の場合(YES)、ステップS304において、その桁の値がvqか否かによって処理を切り分ける。vqの場合には(YES)、正規表現生成部104は特に何も出力せずに次の桁の処理に移行する。vqではない場合には(NO)、正規表現生成部104は、正規表現の出力領域(E)の末尾に“|Ak...Ai+1[(Ai+1)−vq][v1−vq]{i−1}”を追加し、次の桁の処理に移行する。ステップS303において、k−1桁目までの処理が完了していた場合は(NO)、ステップS307に進む。ステップS307において、Akとvjが等しい場合は(YES)、正規表現生成部104は何もせずに処理を終了する。Akとvjが等しくない場合は(NO)、正規表現生成部104はステップS308に進み、正規表現格納領域(E)の末尾に“|[(Ak+1)−vj][v1−vq]{k−1}”を追加し、処理を終了する。処理が終了した時点で正規表現の格納領域(E)に格納されているものが、上記の範囲に対応する正規表現である。
In the processing flow of FIG. 6, the regular
ステップS104における下位領域の正規表現生成処理の流れは、図6においてAn=Bn,...,Ak+1=Bk+1(1≦k≦n)を満たすkに対して下限値と上限値を以下のようにした場合に相当する。
下限値:AkAk−1...A1
上限値:Ak(vq)k−1...(vq)1
そして、ステップS104において、正規表現生成部104が生成する下位領域の正規表現は以下の通りとなる。k+1桁目からn桁目までの値は、ステップS106において、共通部分として処理できるため、ここでも省略している。
下位領域の正規表現:“Ak...A2[A1−vq]|Ak...A3[(A2+1)−vq][v1−vq]|...|Ak[(Ak−1+1)−vq][v1−vq]{k−2}”
N, A n = B flows regular expression generation processing of the lower region, in FIG. 6 at step S104. . . , A k + 1 = B k + 1 (1 ≦ k ≦ n) corresponding to the case where the lower limit value and the upper limit value are set as follows for k.
Lower limit: A k A k−1 . . . A 1
Upper limit value: A k (v q ) k−1 . . . (V q ) 1
In step S104, the regular expression of the lower region generated by the regular
Regular expression of subregion: “A k ... A 2 [A 1 −v q ] | A k ... A 3 [(A 2 +1) −v q ] [v 1 −v q ] | | A k [(A k−1 +1) −v q ] [v 1 −v q ] {k−2} ”
図7は、以下のような属性値の範囲に対応する正規表現の生成処理の流れを示す。
下限値:(vj)k(v1)k−1...(v1)1(ただし、vj≦Bk)
上限値:BkBk−1...B1
FIG. 7 shows the flow of regular expression generation processing corresponding to the following attribute value ranges.
Lower limit value: (v j ) k (v 1 ) k−1 . . . (V 1 ) 1 (where v j ≦ B k )
Upper limit value: B k B k−1 . . . B 1
図7の処理の流れでは、正規表現生成部104は、図6の処理の流れ同様に、最下位の桁から上位の桁に向かって処理を進めている。ここでの入力は、下限値(vj)k(v1)k−1...(v1)1、上限値Bk...B1、及び桁数kである。ステップS401において、正規表現生成部104は、RAM914内の正規表現の格納領域(E)に初期値として“Bk...B2[v1−B1]”をセットする。ステップS402以降では、下位2桁目から始めてk−1桁目までステップS404〜S406の処理を繰り返す。ステップS403において、処理の対象がk桁目より下位の場合(YES)、ステップS404において、その桁の値がv1か否かによって処理を切り分ける。v1の場合には(YES)、正規表現生成部104は特に何も出力せずに次の桁の処理に移行する。v1ではない場合には(NO)、正規表現生成部104は、正規表現の出力領域(E)の末尾に“|Bk...Bi+1[v1−(Bi−1)][v1−vq]{i−1}”を追加し、次の桁の処理に移行する。ステップS403において、k−1桁目までの処理が完了していた場合は(NO)、ステップS407に進む。ステップS407において、Bkとvjが等しい場合は(YES)、正規表現生成部104は何もせずに処理を終了する。Bkとvjが等しくない場合は(NO)、正規表現生成部104はステップS408に進み、正規表現格納領域(E)の末尾に“|[vj−(Bk−1)][v1−vq]{k−1}”を追加し、処理を終了する。処理が終了した時点で正規表現の格納領域(E)に格納されているものが、上記の範囲に対応する正規表現である。
In the processing flow of FIG. 7, the regular
ステップS105における上位領域の正規表現生成処理の流れは、図7においてAn=Bn,...,Ak+1=Bk+1(1≦k≦n)を満たすkに対して下限値と上限値を以下のようにした場合に相当する。
下限値:Bk(v1)k−1...(v1)1
上限値:BkBk−1...B1
そして、ステップS105において、正規表現生成部104が生成する上位領域の正規表現は以下の通りとなる。k+1桁目からn桁目までの値は、ステップS106において、共通部分として処理できるため、ここでも省略している。
上位領域の正規表現:“Bk...B2[v1−B1]|Bk...B3[v1−(B2−1)][v1−vq]|...|Bk[v1−(Bk−1−1)][v1−vq]{k−2}”
The flow of regular expression generation processing for the upper region in step S105 is shown in FIG. 7 as A n = B n,. . . , A k + 1 = B k + 1 (1 ≦ k ≦ n) corresponding to the case where the lower limit value and the upper limit value are set as follows for k.
Lower limit value: B k (v 1 ) k−1 . . . (V 1 ) 1
Upper limit value: B k B k−1 . . . B 1
In step S105, the regular expression of the upper region generated by the regular
Regular expression of the upper area: "B k ... B 2 [ v 1 -B 1] | B k ... B 3 [v 1 - (B 2 -1)] [v 1 -v q] | .. . | B k [v 1 − (B k−1 −1)] [v 1 −v q ] {k−2} ”
以上、属性値の範囲を下位、中位、上位領域に分割し、個別に対応する正規表現を生成する処理について説明した。次に、ステップS106において、正規表現結合部105が、それらの生成された正規表現を結合して生成する正規表現について説明する。
The processing for dividing the attribute value range into the lower, middle, and upper regions and generating the corresponding regular expressions has been described above. Next, the regular expression generated by the regular
正規表現結合部105は、下位、中位、上位領域の正規表現を結合し、結合した正規表現に、ステップS103〜S105において省略されていた共通部分(k+1桁目からn桁目まで)を追加する。これにより最終的に生成される正規表現は以下のような形式となる。
“An...Ak+1(<下位領域の正規表現>|<中位領域の正規表現>|<上位領域の正規表現>)”
また、中位領域がない場合に生成される正規表現は以下のような形式となる。
“An...Ak+1(<下位領域の正規表現>|<上位領域の正規表現>)”
The regular
“A n ... A k + 1 (<Regular expression in lower region> || <Regular expression in middle region> | <Regular expression in upper region>)”
In addition, the regular expression generated when there is no middle region has the following format.
“A n ... A k + 1 (<Regular expression in lower region> | <Regular expression in upper region>)”
上記の正規表現では、A≦X≦Bを満たす値Xだけでなく、値viX、Xvj、viXvjを表す文字列などもヒットしてしまう。そこで、このようなヒットを避けたい場合には、生成した正規表現の前後に除外文字指定“[^v1−vq]”を追加するとよい。 In the regular expression, not only the value X satisfying A ≦ X ≦ B but also a character string representing the values v i X, Xv j , and v i Xv j is hit. Therefore, to avoid such a hit, it is preferable to add an exclusion character designation “[^ v 1 −v q ]” before and after the generated regular expression.
以下、属性範囲条件の上限値と下限値の桁数が異なる場合について説明する。即ち、以下のような場合である。
下限値A:AnAn−1...A2A1
上限値B:BmBm−1...B2B1(m>n)
属性値の桁数が異なるとき、m>nならばB>Aである。又は、下限値Aのn+1桁目からm桁目までは、暗黙の値としてv1があるものと考えることもできる。
Hereinafter, a case where the upper limit value and the lower limit value of the attribute range condition are different will be described. That is, the following cases.
Lower limit A: A n A n-1 . . . A 2 A 1
Upper limit B: B m B m−1 . . . B 2 B 1 (m> n)
When the number of digits of the attribute value is different, B> A if m> n. Or, from n + 1 digit of the lower limit A to the m-th digit it can also be considered that there is v 1 as an implicit value.
まず、m−n=1の場合は、以下のように下位、中位、上位領域を求めることができる。
下位領域:AnAn−1...A2A1〜(vq)n(vq)n−1...(vq)2(vq)1
中位領域:なし
上位領域:(v1)m(v1)m−1...(v1)2(v1)1〜BmBm−1...B2B1
以降の処理の流れについては、図4、図6、図7に示した処理の流れと同じである。
First, when mn = 1, the lower, middle, and upper regions can be obtained as follows.
Subregion: A n A n-1 . . . A 2 A 1 ~ (v q ) n (v q) n-1. . . (V q ) 2 (v q ) 1
Middle region: none Upper region: (v 1 ) m (v 1 ) m−1 . . . (V 1) 2 (v 1 ) 1 ~B m B m-1. . . B 2 B 1
The subsequent processing flow is the same as the processing flow shown in FIG. 4, FIG. 6, and FIG.
もしくは、m−n=1の場合も、図5の処理の流れに従って、以下のように中位領域を求めてもよい。
中位領域:(An+1)(v1)n−1...(v1)2(v1)1〜(Bm−1)(vq)m−1...(vq)2(vq)1
このとき、下位領域と上位領域は以下のようになる。
下位領域:AnAn−1...A2A1〜An(vq)n−1...(vq)2(vq)1
上位領域:Bm(v1)m−1...(v1)2(v1)1〜BmBm−1...B2B1
そして、中位領域の正規表現は以下のようになる。
中位領域の正規表現:“[(An+1)−vq][v1−vq]{n−1}|[v2−(Bm−1)][v1−vq]{m−1}”
Alternatively, even in the case of mn = 1, the middle region may be obtained as follows according to the processing flow of FIG.
Middle region: (A n +1) (v 1 ) n−1 . . . (V 1 ) 2 (v 1 ) 1 to (B m −1) (v q ) m−1 . . . (V q ) 2 (v q ) 1
At this time, the lower area and the upper area are as follows.
Subregion: A n A n-1 . . . A 2 A 1 to An (v q ) n-1 . . . (V q ) 2 (v q ) 1
Upper region: B m (v 1 ) m−1 . . . (V 1) 2 (v 1 ) 1 ~B m B m-1. . . B 2 B 1
And the regular expression of the middle region is as follows.
Regular expression of middle region: “[(A n +1) −v q ] [v 1 −v q ] {n−1} | [v 2 − (B m −1)] [v 1 −v q ] { m−1} ”
また、m−n>2の場合は、下位、中位、上位領域を以下のようにして同様に処理することができる。
下位領域:AnAn−1...A2A1〜(vq)n(vq)n−1...(vq)2(vq)1
中位領域:(v2)n+1(v1)n...(v1)2(v1)1〜(vq)m−1(vq)m−2...(vq)2(vq)1
上位領域:(v2)m(v1)m−1...(v1)2(v1)1〜BmBm−1...B2B1
そして、中位領域の正規表現は以下のようになる。
中位領域の正規表現:“[v2−vq][v1−vq]{n,m−2}”
In the case of mn> 2, the lower, middle and upper areas can be processed in the same manner as follows.
Subregion: A n A n-1 . . . A 2 A 1 ~ (v q ) n (v q) n-1. . . (V q ) 2 (v q ) 1
Middle region: (v 2 ) n + 1 (v 1 ) n . . . (V 1 ) 2 (v 1 ) 1 to (v q ) m-1 (v q ) m-2 . . . (V q ) 2 (v q ) 1
Upper region: (v 2 ) m (v 1 ) m−1 . . . (V 1) 2 (v 1 ) 1 ~B m B m-1. . . B 2 B 1
And the regular expression of the middle region is as follows.
Regular expression of middle region: “[v 2 −v q ] [v 1 −v q ] {n, m−2}”
上記の方式を0以上の整数値に適用した場合の具体例を示す。10進数の場合、v1=0、vq=9である。 A specific example when the above method is applied to an integer value of 0 or more will be described. For decimal numbers, v 1 = 0 and v q = 9.
(例1−1)属性範囲条件:123〜246
下位領域:123〜199
中位領域:200〜199(正規表現は生成されない)
上位領域:200〜246
正規表現:“(12[3−9]|1[3−9][0−9])|(24[0−6]|2[0−3][0−9])”
(Example 1-1) Attribute range condition: 123-246
Lower region: 123-199
Middle region: 200-199 (regular expressions are not generated)
Upper region: 200-246
Regular expression: “(12 [3-9] | 1 [3-9] [0-9]) | (24 [0-6] | 2 [0-3] [0-9])”
(例1−2)属性範囲条件:2345〜7654
下位領域:2345〜2999
中位領域:3000〜6999
上位領域:7000〜7654
正規表現:“(234[5−9]|23[5−9][0−9]|2[4−9][0−9]{2})|[3−6][0−9]{3}|(765[0−4]|76[0−4][0−9]|7[0−5][0−9]{2})”
(Example 1-2) Attribute range condition: 2345-7654
Lower region: 2345-2999
Middle region: 3000-6999
Upper area: 7000-7654
Regular expression: “(234 [5-9] | 23 [5-9] [0-9] | 2 [4-9] [0-9] {2}) | [3-6] [0-9] {3} | (765 [0-4] | 76 [0-4] [0-9] | 7 [0-5] [0-9] {2}) ”
(例1−3)属性範囲条件:7531〜18939
下位領域:7531〜9999
中位領域:10000〜17999
上位領域:18000〜18939
正規表現:“(753[1−9]|75[4−9][0−9])|7[6−9][0−9]{2}|[89][0−9]{3})|1[0−7][0−9]{3}|(1893[0−9]|189[0−2][0−9]|18[0−8][0−9]{2})”
あるいは、
下位領域:7531〜7999
中位領域:8000〜17999
上位領域:18000〜18939
正規表現:“(753[1−9]|75[4−9][0−9])|7[6−9][0−9]{2})|([8−9][0−9]{3}|1[0−7][0−9]{3})|(1893[0−9]|189[0−2][0−9]|18[0−8][0−9]{2})”
(Example 1-3) Attribute range condition: 7531 to 18939
Lower region: 7531 to 9999
Middle region: 10000-17999
Upper region: 18000-18939
Regular expression: “(753 [1-9] | 75 [4-9] [0-9]) | 7 [6-9] [0-9] {2} | [89] [0-9] {3 }) | 1 [0-7] [0-9] {3} | (1893 [0-9] | 189 [0-2] [0-9] | 18 [0-8] [0-9] { 2}) ”
Or
Lower region: 7531-7999
Middle region: 8000-17999
Upper region: 18000-18939
Regular expression: “(753 [1-9] | 75 [4-9] [0-9]) | 7 [6-9] [0-9] {2}) | ([8-9] [0− 9] {3} | 1 [0-7] [0-9] {3}) | (1893 [0-9] | 189 [0-2] [0-9] | 18 [0-8] [0 -9] {2}) "
(例1−4)属性範囲条件:304〜765432
下位領域:304〜999
中位領域:1000〜99999
上位領域:100000〜765432
正規表現:“(30[4−9]|3[1−9][0−9]|[4−9][0−9]{2})|[1−9][0−9]{3,4}|(76543[0−2]|7654[0−2][0−9]|765[0−3][0−9]{2}|76[0−4][0−9]{3}|7[0−5][0−9]{4}|[1−6][0−9]{5})”
(Example 1-4) Attribute range condition: 304 to 765432
Lower area: 304 to 999
Middle region: 1000-99999
Upper area: 100,000 to 765432
Regular expression: “(30 [4-9] | 3 [1-9] [0-9] | [4-9] [0-9] {2}) | [1-9] [0-9] { 3, 4} | (76543 [0-2] | 7654 [0-2] [0-9] | 765 [0-3] [0-9] {2} | 76 [0-4] [0-9 ] {3} | 7 [0-5] [0-9] {4} | [1-6] [0-9] {5}) ”
数値の場合、数値の前に0の連続が許容される場合がある。属性範囲条件にて、「数値の先頭部分に任意の数の0の連続がある」という書式指定がなされた場合には、図4のステップS107において、正規表現結合部105は、正規表現を以下のように生成する。
正規表現:“[^1−9]0*(<下位領域の正規表現>|<中位領域の正規表現>|<上位領域の正規表現>)[^0−9]”
In the case of a numerical value, a continuation of 0 may be allowed before the numerical value. In the attribute range condition, when the format designation “arbitrary number of zeros are continuous at the beginning of the numerical value” is made, in step S107 of FIG. Generate as follows.
Regular expression: “[^ 1-9] 0 * (<Regular expression in lower region> || <Regular expression in middle region> || <Regular expression in upper region>) [^ 0-9]”
また、属性範囲条件にて、「全体の桁数をtとし、不足する場合は先頭に0を補う」という書式指定(C言語のprintf関数の書式指定で記述するところの”%0td”)がなされた場合には、正規表現結合部105は、以下のように正規表現を生成することができる。
正規表現:“[^1−9]0{t−m,0}(0{m−n}<下位領域の正規表現>|<中位領域の正規表現>|<上位領域の正規表現>)[^0−9]”
ここで、中位領域の正規表現は以下のようになる。
中位領域の正規表現:“0{t−n−1}[1−9][0−9]{n}|0{t−n−2}[1−9][0−9]{n+1}|...|0{t−m−1}[1−9][0−9]{m}”
In addition, in the attribute range condition, a format specification (“% 0td” described in the format specification of the C printf function) is “the total number of digits is t, and if there is a shortage, 0 is added at the beginning”. If it is made, the regular
Regular expression: “[^ 1-9] 0 {t−m, 0} (0 {m−n} <regular expression in lower region> | <regular expression in middle region> | <regular expression in upper region>) [^ 0-9] "
Here, the regular expression of the middle region is as follows.
Regular expression of middle region: “0 {t−n−1} [1-9] [0-9] {n} | 0 {tn−2} [1-9] [0-9] {n + 1 } | ... | 0 {tm-1} [1-9] [0-9] {m} "
負の整数の場合は、正規表現生成部104が、まず絶対値に対して同様に正規表現を生成した後で、正規表現の先頭に負号を加えることで生成できる。また、属性値の範囲が0をまたがるような場合には、正(0以上)の領域と、負(0未満)の領域とに分けて処理を行えばよい。例えば、
下限値A:−AnAn−1...A2A1
上限値B:BmBm−1...B2B1
という属性範囲条件が与えられた場合は、
正の下限値:0
正の上限値:BmBm−1...B2B1
及び、
負の下限値:−AnAn−1...A2A1
負の上限値:−1
として個別に正規表現を生成し、正規表現結合部105が最後に以下のように結合すればよい。
正規表現:“<0〜Bの範囲の正規表現>|(−<1〜Aの絶対値の範囲の正規表現>)”
In the case of a negative integer, the regular
Lower limit value A: -A n A n-1 . . . A 2 A 1
Upper limit B: B m B m−1 . . . B 2 B 1
If the attribute range condition is given,
Positive lower limit: 0
Positive upper limit: B m B m−1 . . . B 2 B 1
as well as,
Negative lower limit value: -A n A n-1 . . . A 2 A 1
Negative upper limit: -1
The regular expressions are individually generated as follows, and the regular
Regular expression: “<regular expression in the range of 0 to B> | (− <regular expression in the range of absolute values of 1 to A>)”
これまでの説明では、属性値の下限値A、上限値Bともに指定されている場合について示してきた。ここでは、上限値Bの指定がない場合や上限値が「無限大」と指定された場合について説明する。属性のデータ型として最大値B´が存在する場合は、正規表現結合部105は下限値Aから上限値B´までの正規表現を生成すればよい。属性のデータ型として最大値がない場合には、以下のように処理するとよい。
In the description so far, the case where both the lower limit value A and the upper limit value B of the attribute value are specified has been shown. Here, a case where the upper limit value B is not specified or a case where the upper limit value is specified as “infinity” will be described. When the maximum value B ′ exists as the attribute data type, the regular
まず、正規表現結合部105は、下限値Aと同じ桁数の属性値の最大値について正規表現を生成する。即ち、以下のようなn桁の下限値と上限値について正規表現を生成する。
下限値A:An...A1
上限値B´:(vq)n...(vq)1
その上で、正規表現結合部105は、n桁目より上位の属性値の正規表現“[v2−vq][v1−vq]{n,}”を追加する。生成される正規表現は以下の形式になる。
正規表現:“<A〜B´の範囲の正規表現>|[v2−vq][v1−vq]{n,}”
First, the regular
Lower limit value A: An . . . A 1
Upper limit B ′: (v q ) n . . . (V q ) 1
Then, the regular
Regular expression: “<Regular expression in the range of A to B ′> | [v 2 −v q ] [v 1 −v q ] {n,}”
下限値Aの指定がない場合や下限値が「無限小」と指定された場合について説明する。まず、属性のデータ型として最小値A´があるならば、正規表現結合部105は下限値A´と上限値Bについて正規表現を生成するようにすればよい。例えば、検索対象の属性のデータ型が正の整数であれば最小値は1であるし、自然数であれば最小値は0である。負の整数値も含む場合は、正規表現結合部105は、これまでに示してきた手順に従って以下のような正規表現を生成すればよい。即ち、0〜Bの数値範囲と、1桁以上の負の数値として考える。なお、以下の正規表現の記述例では、0回以上の繰り返しを“{0,}”の代わりに“*”で表している。
正規表現:“<0〜Bの範囲の正規表現>|(−[1−9][0−9]*)”
A case where the lower limit value A is not specified or a case where the lower limit value is specified as “infinitesimal” will be described. First, if there is a minimum value A ′ as an attribute data type, the regular
Regular expression: "<Regular expression in the range of 0 to B> | (-[1-9] [0-9] *)"
数字に全角と半角数字が、アルファベット(英字)に大文字と小文字があるように、属性の各桁の値域が2種類以上存在する場合がある(v1≦Ai≦vq,w1≦Ai≦wq,...)。その場合でも、正規表現結合部105が、上で示した処理の流れを少し修正するだけで、対応する正規表現を生成することができる。即ち、2種類以上の属性値の記述を区別しないという指定がなされた場合には、選択「|」や文字クラスを使用して並べて記述することで生成することができる。例を示す。
(1)選択を使用する場合
修正前:“vivj[vk−vl]”
修正後:“(vivj[vk−vl]|wiwj[wk−wl]|...)”
(2)文字クラスを使用する場合
修正前:“vivj[vk−vl]”
修正後:“[viwi...][vjwj...][vk−vlwk−wl...]”
There may be two or more value ranges for each digit of the attribute, such that there are full-width and half-width numbers in the numbers and uppercase and lowercase letters in the alphabet (alphabetic characters) (v 1 ≦ A i ≦ v q , w 1 ≦ A i ≦ w q ,. Even in such a case, the regular
(1) When using selection Before modification: “v i v j [v k −v l ]”
After correction: “(v i v j [v k −v l ] | w i w j [w k −w l ] |...)”
(2) When using a character class Before modification: “v i v j [v k −v l ]”
After correction: “[v i w i ...] [V j w j ...] [V k −v l w k −w l .
数値の場合には、下位の桁から3桁ごとにカンマ「,」で区切られる場合がある。その場合の正規表現の記述は以下のようになる。このとき、上で示した処理の流れによると、下位領域や上位領域の正規表現は桁数が固定である。以下の例では、正規表現の選択記号「|」に囲まれた部分正規表現についてのみ示す。
修正前:“AmAm−1...An+1[v1−vq]{n}”
修正後:“AmAm−1...An−t+4,An−t+3...An+1[v1−vq]{t}(,[v1−vq]{3}){s}”
ここで、sはn/3の商、tはn/3の余剰とする。
このように、正規表現結合部105は、n+1桁目以上については、n−t+3×i桁目とn−t+3×i+1桁目との間にカンマを挿入するとよい(iは自然数)。
In the case of numerical values, every three digits from the lower digit may be separated by a comma “,”. The description of the regular expression in that case is as follows. At this time, according to the processing flow shown above, the regular expression of the lower area and the upper area has a fixed number of digits. In the following example, only a partial regular expression surrounded by a regular expression selection symbol “|” is shown.
Before correction: “A m A m−1 ... A n + 1 [v 1 −v q ] {n}”
After the modification: “A m A m−1 ... A n−t + 4 , A n−t + 3 ... A n + 1 [v 1 −v q ] {t} (, [v 1 −v q ] {3}) {S} ”
Here, s is a quotient of n / 3, and t is a surplus of n / 3.
As described above, the regular
上記の例では、10進数の場合について示したが、v1=0、vq=Fとすれば16進数も同様に処理することができる。その他、本実施の形態と同様の形式を持つ属性であれば、いずれも同様に処理することができる。 In the above example, the case of a decimal number is shown. However, if v 1 = 0 and v q = F, a hexadecimal number can be processed in the same manner. In addition, any attribute having the same format as the present embodiment can be processed in the same manner.
さらに、ここまで、主に整数値の例を用いて説明してきたが、各桁の値は数字である必要はなく、1桁以上の数値や、順序のある単語の集合でもよい。例えば、日付の月の表記の仕方には、月の英語名(January、February、March、・・・、December)やその略語(Jan、Feb、Mar、・・・、Dec)が使用される場合もある。この場合、月を12個の値を持つ1個の属性要素と見なしてもよい。このとき、v1=“Jan”、v2=“Feb”、v3=“Mar”、・・・、v12=“Dec”と定義すれば、本実施の形態において示した手順で処理することができる。このような処理方法は、属性値が後述する実施の形態3に示す形式を持つような場合、特に有効である。 Furthermore, although the description has been made mainly using the example of the integer value so far, the value of each digit does not have to be a number, and may be a numerical value of one digit or more or a set of ordered words. For example, when the month of the date is used, the English name of the month (January, February, March, ..., December) or its abbreviation (Jan, Feb, Mar, ..., Dec) is used. There is also. In this case, the month may be regarded as one attribute element having 12 values. At this time, if v 1 = “Jan”, v 2 = “Feb”, v 3 = “Mar”,..., V 12 = “Dec”, processing is performed according to the procedure shown in this embodiment. be able to. Such a processing method is particularly effective when the attribute value has the format shown in the third embodiment to be described later.
以上のように、本実施の形態に係る正規表現生成装置100によれば、整数値のような特徴を持った属性の下限値、上限値、書式などを指定した属性範囲条件から、その下限値から上限値までの範囲に含まれる属性値を表現する文字列を照合するための正規表現を自動的に生成することができる。これにより、従来は正確に記述することが困難であった複雑な属性範囲条件を照合する正規表現を、特別な知識も試行錯誤も必要なく、容易に短時間で得ることができる。
As described above, according to the regular
実施の形態2.
本実施の形態について、主に実施の形態1との差異を説明する。
In the present embodiment, differences from the first embodiment will be mainly described.
実施の形態1で説明したように、整数値のデータ型や書式の指定の仕方には様々なものがある。例えば、符合の有無、最大桁数、何進数表記であるか、整数値の値域、数値の先頭の0の有無、カンマ区切りの有無、表記する文字の種類、・・・など、これらの書式を属性範囲条件で細かく指定するのは煩雑である。そこで、本実施の形態では、正規表現生成装置100において、予め設定された属性範囲条件を記憶装置151に記憶しておき、これを選択して利用できるようにする。
As described in the first embodiment, there are various ways of specifying the data type and format of the integer value. For example, these formats such as presence / absence of sign, maximum number of digits, decimal number notation, integer value range, presence / absence of leading zeros, presence / absence of comma delimiters, type of characters to be written, etc. It is complicated to specify the attribute range condition in detail. Therefore, in the present embodiment, in the regular
図8は、本実施の形態に係る正規表現生成装置100の構成を示すブロック図である。
FIG. 8 is a block diagram showing a configuration of regular
図8において、正規表現生成装置100は、実施の形態1で説明した図1に示したものに加え、条件記憶部107、識別子入力部108を備える。
In FIG. 8, the regular
条件記憶部107は、複数の属性範囲条件データを予め記憶装置151に記憶しておく。条件記憶部107は、各属性範囲条件データを一意の識別子と対応付けて記憶装置151に記憶する。
The
識別子入力部108は、任意の識別子を入力装置153から入力する。
The
属性範囲条件入力部101は、識別子入力部108により入力された識別子に対応付けて条件記憶部107により記憶された属性範囲条件データを入力する。
The attribute range
図9は、本実施の形態に係る正規表現生成方法を示すフローチャートである。図9のフローチャートに示すフローは、正規表現生成装置100を実現するコンピュータ上で実行されるプログラム(正規表現生成プログラム)の処理手順に相当する。この処理手順において、正規表現生成プログラムは、以下に示す各処理をコンピュータに実行させる。
FIG. 9 is a flowchart showing a regular expression generation method according to the present embodiment. The flow shown in the flowchart of FIG. 9 corresponds to a processing procedure of a program (regular expression generation program) executed on a computer that implements the regular
正規表現生成装置100の利用者がキーボード902やマウス903で識別子を指定すると、識別子入力部108は、その識別子をキーボード902やマウス903から入力する(ステップS501:識別子入力処理)。属性範囲条件入力部101は、条件記憶部107により磁気ディスク装置920に予め記憶されている複数の属性範囲条件データの中から、識別子入力部108により入力された識別子に対応付けて記憶された属性範囲条件データを読み出して入力する(ステップS502:属性範囲条件入力処理)。ステップS502の後は、実施の形態1で説明した図4のフローチャートと同様に、ステップS103〜S107の処理が実行される。
When the user of the regular
このように、本実施の形態において、正規表現生成装置100は、正規表現を生成する処理のために参照可能な記憶装置151内の記憶領域の一部に、正規表現生成規則(即ち、属性範囲条件)を記憶するための領域を設けておき、識別番号や識別名(いずれも識別子の一例)と属性値の書式や正規表現の生成手順(いずれも属性範囲条件に含まれる情報の一例)を組にして記憶しておく。属性範囲条件として、属性の下限値と上限値は、実施の形態1と同様にその都度指定し、属性の書式だけは、それを特定する識別番号や識別名を指定するようにしてもよい。また、このとき、属性範囲条件入力部101が、指定された識別番号や識別名に対応する書式の情報や正規表現生成手順を記憶装置151から読み出し、正規表現生成部104や正規表現結合部105が、その手順に従って正規表現を生成するようにしてもよい。あるいは、属性範囲条件入力部101が、属性の下限値と上限値を文字列で入力するようにし、正規表現生成部104や正規表現結合部105が、入力された文字列を分析してカンマ区切りの有無などを自動的に判別するようにしてもよい。
As described above, in the present embodiment, the regular
さらに、正規表現生成規則を記憶するための領域を書き換え可能な領域に定義しておき、条件記憶部107が、属性の書式を表す識別番号や識別名と、属性のデータ型、書式、正規表現の生成手順などの情報をこの領域に追加できるようにしてもよい。
Further, an area for storing the regular expression generation rule is defined as a rewritable area, and the
正規表現生成規則を記憶するための領域は、ディスク装置や不揮発性メモリなどの記憶装置151に記憶され、正規表現の生成手順を実行する処理装置152から読み出すことができるように構成してもよいし、実行時には高速な不揮発性メモリ上に記憶されるように構成してもよい。
The area for storing the regular expression generation rule may be configured to be stored in the
実施の形態3.
本実施の形態について、主に実施の形態1との差異を説明する。
Embodiment 3 FIG.
In the present embodiment, differences from the first embodiment will be mainly described.
本実施の形態は、実施の形態1と異なる形式の属性について、正規表現を生成する処理の流れを説明するものである。本実施の形態における正規表現生成装置100の構成は、実施の形態1で説明した図1に示したものと同じである。また、正規表現生成装置100の動作(正規表現生成方法、正規表現生成プログラムの処理手順)は、実施の形態1で説明した図4に示したものと同じである。
In the present embodiment, a flow of processing for generating a regular expression for an attribute having a format different from that in the first embodiment will be described. The configuration of regular
以下、実施の形態1と同様に、正規表現を生成する処理の流れを、例を交えて説明する。ここで説明するのは、属性範囲条件の下限値Aと上限値Bに対して、A≦X<Bを満たす値X(下限値Aから上限値Bまでの属性値X)を表現する文字列を照合するための正規表現を生成する処理の流れである。 Hereinafter, as in the first embodiment, the flow of processing for generating a regular expression will be described with an example. What is described here is a character string expressing a value X (attribute value X from lower limit value A to upper limit value B) that satisfies A ≦ X <B with respect to lower limit value A and upper limit value B of the attribute range condition. This is a flow of processing for generating a regular expression for matching.
実施の形態1とは異なり、ここでの属性値を以下のように表すものとする。
下限値A:A1A2...An−1An
上限値B:B1B2...Bm−1Bm
Ai、Bj(1≦i≦n、1≦j≦m)は、それぞれ1個の数字や文字で、その値域をv1≦Ai、Bj≦vqとする。本実施の形態における属性値の大小関係は、次の順序で決まるものとする。
(1)A1=B1,A2=B2,...,Ak−1=Bk−1(1≦k≦n又はm)のとき、Bk>AkならばB>A
(2)A1=B1,A2=B2,...,An=Bnでかつm>nならばB>A
Ai+1と記述してAiの値を1大きくすることとし、Ai=vjの場合Ai+1=vj+1とする。ただし、Ai=vqの場合はAi+1=v1とし、さらにAi+1+1とする。同様に、Ai−1と記述してAiの値を1小さくすることとし、Ai=vjの場合Ai−1=vj−1とする。ただし、Ai=v1の場合はAi−1=vqとし、さらにAi+1−1とする。属性値Aを1大きくすることをA+1と記述し、An+1を意味するものとする。同様に、属性値Aを1小さくすることをA−1と記述し、An−1と意味するものとする。
Unlike the first embodiment, the attribute values here are expressed as follows.
Lower limit A: A 1 A 2 . . . A n-1 An
Upper limit B: B 1 B 2 . . . B m-1 B m
A i and B j (1 ≦ i ≦ n, 1 ≦ j ≦ m) are each a single number or letter, and their ranges are v 1 ≦ A i and B j ≦ v q . The magnitude relationship between attribute values in the present embodiment is determined in the following order.
(1) A 1 = B 1 , A 2 = B 2 ,. . . , A k−1 = B k−1 (1 ≦ k ≦ n or m), B> A if B k > A k
(2) A 1 = B 1 , A 2 = B 2 ,. . . , A n = B n and m> n, B> A
A i +1 is described to increase the value of A i by 1. When A i = v j , A i + 1 = v j + 1 . However, when A i = v q , A i + 1 = v 1 and further A i + 1 +1. Similarly, A i −1 is described, and the value of A i is decreased by 1. When A i = v j , A i −1 = v j−1 . However, when A i = v 1 , A i −1 = v q, and further A i + 1 −1. Increasing the attribute value A by 1 is described as A + 1, which means A n +1. Similarly, reducing the attribute value A by 1 is described as A-1, and is assumed to be A n -1.
このような特徴を持つ属性値としては、文字列(辞書式順)や小数点数の小数部分(小数点以下の値)などがある。 Attribute values having such characteristics include a character string (in lexicographic order) and a decimal part of a decimal point (value after the decimal point).
ここで、下限値Aと上限値Bが等しい場合は、ステップS102を実行するまでもなく以下の正規表現を出力するだけでよい。
正規表現:“A1A2...An−1An”
Here, if the lower limit value A and the upper limit value B are equal, it is only necessary to output the following regular expression without executing step S102.
Regular expression: “A 1 A 2 ... A n-1 A n ”
以降は、下限値と上限値が等しくない場合について説明する。 Hereinafter, a case where the lower limit value and the upper limit value are not equal will be described.
ステップS102では、演算部102は、属性値を下位、中位、上位の3領域に分割する。このとき、まずは下限値と上限値で桁数の少ない方に合わせて考えるとよい。
In step S102, the
まず、以下のようなr桁の下限値A´と上限値B´に対して、中位領域を求める。
下限値A´:A1A2...Ar−1Ar
上限値B´:B1B2...Br−1Br
ここでrはnとmの値の小さい方とする。中位領域を求める処理の流れを図10に示す。図10は、図5のステップS201を「i=1」とし、ステップS204、S206を「i=i+1」とし、ステップS207を「i≦r?」としたものである。
First, the middle region is obtained for the r-digit lower limit value A ′ and upper limit value B ′ as follows.
Lower limit value A ′: A 1 A 2 . . . A r-1 A r
Upper limit B ′: B 1 B 2 . . . B r-1 B r
Here, r is the smaller of n and m. FIG. 10 shows a flow of processing for obtaining the middle region. In FIG. 10, step S201 in FIG. 5 is set to “i = 1”, steps S204 and S206 are set to “i = i + 1”, and step S207 is set to “i ≦ r?”.
図10において、演算部102は、最下位桁(1桁目)から順番に(ステップS601)属性値の下限値A´と上限値B´の同じ桁の値をCPU911により比較していく(ステップS602)。ある桁(i桁目)について、A´とB´とで値が同じ場合、演算部102は、LとUの同じ桁(Li、Ui)もその値(Ai)に設定し(ステップS603)、次の桁について(ステップS604)A´とB´を比較する。比較した桁について、A´とB´とで値が異なる場合、演算部102は、Lの同じ桁(Li)をA´の値より1大きい値(Ai+1)に設定するとともに、Uの同じ桁(Ui)をB´の値より1小さい値(Bi−1)に設定する(ステップS605)。そして、次の桁からr桁目までの各桁について(ステップS606、S607)、Lをその桁の最小値(v1)に設定するとともに、Uをその桁の最大値(vq)に設定する(ステップS608)。その結果、中位領域の下限値Lと上限値Uが得られる。このとき、属性値記憶部103はLとUをRAM914に記憶している。
In FIG. 10, the
上記の手順に従うと、演算部102は、次のように下位領域(A´〜L−1)、中位領域(L〜U)、上位領域(U+1〜B´)を求めることができる。
下位領域:A1A2...Ar−1Ar〜A1...Ak(vq)k−1...(vq)r
中位領域:A1...Ak−1(Ak+1)(v1)k+1...(v1)r〜B1...Bk−1(Bk−1)(vq)k+1...(vq)r
上位領域:B1...Bk(v1)k−1...(v1)r〜B1B2...Br−1Br
ただし、A1=B1,...,Ak−1=Bk−1(1≦k≦r)
このとき、属性値記憶部103は下限値A´、上限値B´、第1の値(L−1)、第2の値(U+1)をRAM914に記憶している。
According to the above procedure, the
Subregion: A 1 A 2 . . . A r-1 A r to A 1 . . . A k (v q ) k−1 . . . (V q ) r
Middle region: A 1 . . . A k-1 (A k +1) (v 1 ) k + 1 . . . (V 1 ) r -B 1 . . . B k−1 (B k −1) (v q ) k + 1 . . . (V q ) r
Upper region: B 1 . . . B k (v 1 ) k−1 . . . (V 1 ) r to B 1 B 2 . . . B r-1 B r
However, A 1 = B 1 ,. . . , A k−1 = B k−1 (1 ≦ k ≦ r)
At this time, the attribute
続いて、n>mの場合は、演算部102は、下位領域にr+1桁目からn桁目までを追加する。
下位領域:A1...ArAr+1...An〜A1...Ak(vq)k−1...(vq)r(vq)r+1...(vq)n
一方、n<mの場合は、演算部102は、上位領域にr+1桁目からm桁目までを追加する。
上位領域:B1...Bk(v1)k−1...(v1)r(v1)r+1...(v1)m〜B1...BrBr+1...Bm
Subsequently, when n> m, the
Lower region: A 1 . . . A r A r + 1 . . . An to A 1 . . . A k (v q ) k−1 . . . (V q ) r (v q ) r + 1 . . . (V q ) n
On the other hand, when n <m, the
Upper region: B 1 . . . B k (v 1 ) k−1 . . . (V 1 ) r (v 1 ) r + 1 . . . (V 1 ) m to B 1 . . . B r B r + 1 . . . B m
ステップS103において、正規表現生成部104は、中位領域の正規表現を生成する。中位領域の正規表現は、中位領域のAk、Bkの値にのみ依存し、以下の通り生成することができる。1桁目からk−1桁目までの値は、ステップS106において、共通部分として処理できるため、ここでは省略している。
中位領域の正規表現:“[(Ak+1)−(Bk−1)]”
ここで、Bk−Ak=1の場合、(Ak+1)>(Bk−1)となるが、この場合は中位領域の正規表現を出力しないものとする。それ以外は同様に処理することができる。
In step S103, the regular
Regular expression in the middle region: “[(A k +1) − (B k −1)]”
Here, when B k −A k = 1, (A k +1)> (B k −1) is satisfied. In this case, the regular expression of the middle region is not output. Other than that, it can process similarly.
図11は、以下のような属性値の範囲に対応する正規表現の生成処理の流れを示す。
下限値:AkAk−1...An
上限値:(vj)k(vq)k−1...(vq)n(ただし、vj≧Ak)
FIG. 11 shows the flow of processing for generating a regular expression corresponding to the following attribute value ranges.
Lower limit: A k A k−1 . . . An
Upper limit value: (v j ) k (v q ) k−1 . . . (V q ) n (where v j ≧ A k )
図11の処理の流れは、図6に示したものとほぼ同じであり、正規表現生成部104は、最下位の桁から上位の桁に向かって処理を進める。ステップS701において、正規表現生成部104は、RAM914内の正規表現の格納領域(E)に初期値として“Ak...Anー1[An−vq]”をセットする。ステップS702以降では、下位2桁目から始めてk+1桁目までステップS704〜S706の処理を繰り返す。ステップS703において、処理の対象がk桁目より下位の場合(YES)、ステップS704において、その桁の値がvqか否かによって処理を切り分ける。vqの場合には(YES)、正規表現生成部104は特に何も出力せずに次の桁の処理に移行する。vqではない場合には(NO)、正規表現生成部104は、正規表現の出力領域(E)の末尾に“|Ak...Ai−1[(Ai+1)−vq]”を追加し、次の桁の処理に移行する。ステップS703において、k+1桁目までの処理が完了していた場合は(NO)、ステップS707に進む。ステップS707において、Akとvjが等しい場合は(YES)、正規表現生成部104は何もせずに処理を終了する。Akとvjが等しくない場合は(NO)、正規表現生成部104はステップS708に進み、正規表現格納領域(E)の末尾に“|[(Ak+1)−vj]”を追加し、処理を終了する。処理が終了した時点で正規表現の格納領域(E)に格納されているものが、上記の範囲に対応する正規表現である。
The processing flow in FIG. 11 is almost the same as that shown in FIG. 6, and the regular
ステップS104における下位領域の正規表現生成処理の流れは、図11においてA1=B1,...,Ak−1=Bk−1(1≦k≦n)を満たすkに対して下限値と上限値を以下のようにした場合に相当する。
下限値:AkAk+1...An
上限値:Ak(vq)k+1...(vq)n
そして、ステップS104において、正規表現生成部104が生成する下位領域の正規表現は以下の通りとなる。1桁目からk−1桁目までの値は、ステップS106において、共通部分として処理できるため、ここでも省略している。
下位領域の正規表現:“AkAk+1...An−1[An−vq]|AkAk+1...An−2[(An−1+1)−vq]|...|Ak[(Ak+1+1)−vq]”
A 1 = B 1, the flow of regular expression generation processing of the lower region, in FIG. 11 in step S104. . . , A k−1 = B k−1 (1 ≦ k ≦ n), this corresponds to the case where the lower limit value and the upper limit value are set as follows for k.
Lower limit: A k A k + 1 . . . An
Upper limit value: A k (v q ) k + 1 . . . (V q ) n
In step S104, the regular expression of the lower region generated by the regular
Regular expression of the sub-regions: "A k A k + 1 ... A n-1 [A n -v q] | A k A k + 1 ... A n-2 [(A n-1 +1) -v q] | ... | A k [(A k + 1 +1) −v q ] ”
図12は、以下のような属性値の範囲に対応する正規表現の生成処理の流れを示す。
下限値:(vj)k(v1)k+1...(v1)m(ただし、vj≦Bk)
上限値:BkBk+1...Bm
FIG. 12 shows the flow of processing for generating a regular expression corresponding to the following attribute value ranges.
Lower limit value: (v j ) k (v 1 ) k + 1 . . . (V 1 ) m (where v j ≦ B k )
Upper limit value: B k B k + 1 . . . B m
図12の処理の流れは、図7に示したものとほぼ同じであり、正規表現生成部104は、最下位の桁から上位の桁に向かって処理を進める。ステップS801において、正規表現生成部104は、RAM914内の正規表現の格納領域(E)に初期値として“Bk...Bm−1[v1−(Bm−1)]”をセットする。ステップS802以降では、下位2桁目から始めてk+1桁目までステップS804〜S806の処理を繰り返す。ステップS803において、処理の対象がk桁目より下位の場合(YES)、ステップS804において、その桁の値がv1か否かによって処理を切り分ける。v1の場合には(YES)、正規表現生成部104は特に何も出力せずに次の桁の処理に移行する。v1ではない場合には(NO)、正規表現生成部104は、正規表現の出力領域(E)の末尾に“|Bk...Bi+1[v1−(Bi−1)]”を追加し、次の桁の処理に移行する。ステップS803において、k+1桁目までの処理が完了していた場合は(NO)、ステップS807に進む。ステップS807において、Bkとvjが等しい場合は(YES)、正規表現生成部104は何もせずに処理を終了する。Bkとvjが等しくない場合は(NO)、正規表現生成部104はステップS808に進み、正規表現格納領域(E)の末尾に“|[vj−(Bk−1)]”を追加し、処理を終了する。処理が終了した時点で正規表現の格納領域(E)に格納されているものが、上記の範囲に対応する正規表現である。
The processing flow in FIG. 12 is almost the same as that shown in FIG. 7, and the regular
ステップS105における上位領域の正規表現生成処理の流れは、図12においてA1=B1,...,Akー1=Bkー1(1≦k≦m)を満たすkに対して下限値と上限値を以下のようにした場合に相当する。
下限値:Bk(v1)k+1...(v1)m
上限値:BkBk+1...Bm
そして、ステップS105において、正規表現生成部104が生成する上位領域の正規表現は以下の通りとなる。1桁目からk−1桁目までの値は、ステップS106において、共通部分として処理できるため、ここでも省略している。
上位領域の正規表現:“BkBk+1...Bm−1[v1−(Bm−1)]|BkBk+1...Bm−2[v1−(Bm−1−1)]|...|Bk[v1−(Bk+1−1)]”
The flow of regular expression generation processing for the upper region in step S105 is as follows: A 1 = B 1 ,. . . , A k−1 = B k−1 (1 ≦ k ≦ m), this corresponds to the case where the lower limit value and the upper limit value are set as follows for k.
Lower limit: B k (v 1 ) k + 1 . . . (V 1 ) m
Upper limit value: B k B k + 1 . . . B m
In step S105, the regular expression of the upper region generated by the regular
Regular expression of upper region: “B k B k + 1 ... B m−1 [v 1 − (B m −1)] | B k B k + 1 ... B m−2 [v 1 − (B m−1 -1)] | ... | B k [v 1 - (B k + 1 -1)] "
ステップS106において、正規表現結合部105は、ステップS103〜S105で個別に生成された下位、中位、上位領域の正規表現を結合し、結合した正規表現に、ステップS103〜S105で省略されていた共通部分(1桁目からk−1桁目まで)を追加して、属性範囲条件に対応する正規表現を生成する。この正規表現は、属性範囲条件の下限値と上限値の共通部分と、下位、中位、上位領域の正規表現から、以下のような形となる。
“A1...Ak−1(<下位領域の正規表現>|<中位領域の正規表現>|<上位領域の正規表現>)”
また、中位領域がない場合に生成される正規表現は以下のような形式となる。
“A1...Ak−1(<下位領域の正規表現>|<上位領域の正規表現>)”
In step S106, the regular
“A 1 ... A k-1 (<Regular expression of lower region> | <Regular expression of middle region> | <Regular expression of upper region>)”
In addition, the regular expression generated when there is no middle region has the following format.
“A 1 ... A k-1 (<Regular expression in lower region> | <Regular expression in upper region>)”
このような正規表現では、正規表現に記述された1又はn又はm文字まで文字列を照合した時点で、文字の照合を停止してしまう。よって、それよりも長い文字列については、ヒットはするものの、その文字列の末尾の位置まではわからないことがある。そこで、正規表現にヒットする文字列の終端の位置まで知りたい場合は、正規表現の末尾に“[v1−vq]*”を追加すればよい。 In such a regular expression, character collation is stopped when a character string is collated up to 1 or n or m characters described in the regular expression. Therefore, a character string longer than that may hit, but may not know the position at the end of the character string. Therefore, when it is desired to know the position of the end of the character string hitting the regular expression, “[v 1 −v q ] *” may be added to the end of the regular expression.
また、上記の正規表現では、A≦X<Bを満たす値Xだけでなく、値viXもヒットしてしまう。そこで、このようなヒットを避けたい場合には、正規表現の先頭に除外文字指定“[^v1−vq]”を追加するとよい。 In the regular expression, not only the value X satisfying A ≦ X <B but also the value v i X is hit. Therefore, in order to avoid such a hit, an exclusion character designation “[^ v 1 −v q ]” may be added to the head of the regular expression.
上記の方式を英小文字の文字列に適用した場合(全角英小文字又は半角英小文字いずれか1種類の場合)の具体例を示す。ここで、v1=a、vq=zである。 A specific example in the case where the above method is applied to a lowercase character string (in the case of either one type of lowercase alphabet or lowercase alphabet) is shown. Here, v 1 = a and v q = z.
(例3−1)属性範囲条件:「end」〜「start」
下位領域:「end」〜「ezz」
中位領域:「faa」〜「rzz」
上位領域:「saaaa」〜「start」
正規表現:“(en[d−z]|e[o−z])|[f−r]|(star[a−s]|sta[a−q]|s[a−s])”
(Example 3-1) Attribute range condition: “end” to “start”
Lower region: “end” to “ezz”
Middle region: “faa” to “rzz”
Upper area: “saaa” to “start”
Regular expression: “(en [d−z] | e [o−z]) | [fr] | (star [a−s] | sta [a−q] | s [a−s])”
また、上記の方式を0<A、B≦1となる下限値Aと上限値Bに適用した場合の具体例を示す。 A specific example in which the above method is applied to the lower limit value A and the upper limit value B satisfying 0 <A and B ≦ 1 is shown.
(例3−2)属性範囲条件:0.00321〜0.876
下位領域:0.00321〜0.09999
中位領域:0.100〜0.799
上位領域:0.800〜0.876
正規表現:“0.((0032[1−9]|003[3−9]|00[4−9]|0[1−9])|[1−7]|(87[0−5]|8[0−6]))”
(Example 3-2) Attribute range condition: 0.00321 to 0.876
Lower region: 0.00321 to 0.09999
Middle region: 0.100 to 0.799
Upper area: 0.800 to 0.876
Regular expression: “0. ((0032 [1-9] | 003 [3-9] | 00 [4-9] | 0 [1-9]) | [1-7] | (87 [0-5] | 8 [0-6])) "
これまでの説明では、属性値の下限値A、上限値Bともに指定されている場合について示してきた。ここでは、上限値Bの指定がない場合や上限値が「無限大」と指定された場合について説明する。属性のデータ型として最大値B´が存在する場合は、正規表現結合部105は下限値Aから上限値B´までの正規表現を生成すればよい。属性のデータ型として最大値がない場合には、以下のように処理するとよい。
In the description so far, the case where both the lower limit value A and the upper limit value B of the attribute value are specified has been shown. Here, a case where the upper limit value B is not specified or a case where the upper limit value is specified as “infinity” will be described. When the maximum value B ′ exists as the attribute data type, the regular
まず、正規表現結合部105は、下限値Aと同じ桁数の属性値の最大値について正規表現を生成する。即ち、以下のようなn桁の下限値と上限値について正規表現を生成する。
下限値A:A1...An
上限値B´:(vq)1...(vq)n
その上で、正規表現結合部105は、(vq)1...(vq)n...の正規表現“vq{n}[v1−vq]*[v2−vq]”を追加する。生成される正規表現は以下の形式になる。
正規表現:“<A〜B´の範囲の正規表現>|vq{n}[v1−vq]*[v2−vq]”
First, the regular
Lower limit A: A 1 . . . An
Upper limit B ′: (v q ) 1 . . . (V q ) n
In addition, the regular
Regular expression: “<Regular expression in the range of A to B ′> | v q {n} [v 1 −v q ] * [v 2 −v q ]”
下限値Aの指定がない場合や下限値が「無限小」と指定された場合について説明する。まず、属性のデータ型として最小値A´があるならば、正規表現結合部105は下限値A´と上限値Bについて正規表現を生成するようにすればよい。それ以外の場合は、以下のような下限値A´と上限値Bについて正規表現を生成すればよい。
下限値A´:(v1)1
上限値B:B1...Bm
A case where the lower limit value A is not specified or a case where the lower limit value is specified as “infinitesimal” will be described. First, if there is a minimum value A ′ as an attribute data type, the regular
Lower limit value A ′: (v 1 ) 1
Upper limit B: B 1 . . . B m
英字に大文字と小文字が、文字に全角文字と半角文字があるように、属性の各桁の値域が2種類以上存在する場合がある。その場合は、実施の形態1の属性と同様に、選択「|」や文字クラスを使用して並べて記述することにより、対応する正規表現を生成することができる。 There may be two or more value ranges for each digit of the attribute such that uppercase and lowercase letters are used for letters and full-width and half-width letters are used for letters. In that case, as in the attribute of the first embodiment, the corresponding regular expression can be generated by using the selection “|” and the character class to describe them side by side.
以上のように、本実施の形態に係る正規表現生成装置100によれば、文字列のような特徴を持つ属性値の下限値、上限値、書式などを指定した属性範囲条件から、その下限値から上限値までの範囲に含まれる属性値を表現する文字列を照合するための正規表現を自動的に生成することができる。これにより、従来は正確に記述することが困難であった複雑な属性範囲条件を照合する正規表現を、特別な知識も試行錯誤も必要なく、容易に短時間で得ることができる。
As described above, according to the regular
実施の形態4.
本実施の形態について、主に実施の形態1との差異を説明する。
Embodiment 4 FIG.
In the present embodiment, differences from the first embodiment will be mainly described.
本実施の形態は、複数の属性値と、属性値間を区切る区切り文字とから構成される階層構造を持つ属性について、その正規表現を生成する処理の流れを説明するものである。本実施の形態における正規表現生成装置100の構成は、実施の形態1で説明した図1に示したものと同じである。また、正規表現生成装置100の動作(正規表現生成方法、正規表現生成プログラムの処理手順)は、実施の形態1で説明した図4に示したものと同じである。上記のような階層構造を持つ形式の属性の正規表現を生成するため、正規表現生成装置100は、階層構造における最上位の階層から順に下位の階層に向かって、実施の形態1や3と同様の手順を適用することにより、正規表現を生成していく。
In the present embodiment, the flow of processing for generating a regular expression for an attribute having a hierarchical structure composed of a plurality of attribute values and delimiters that separate attribute values will be described. The configuration of regular
本実施の形態では、正規表現生成装置100の利用者は属性の上限値、下限値、区切り文字、階層の順序、各階層の属性の形式、値域などを属性範囲条件データとして指定する。そして、ステップS101では、属性範囲条件入力部101が、その属性範囲条件データを入力する。つまり、属性範囲条件入力部101は、属性値の書式として、属性値が区切り文字を用いた階層構造をとる属性値であり、属性値全体を区切り文字で区切った部分の各々がその階層構造の1階層であることを示す属性範囲条件データを入力する。このような階層構造を持つ属性値としては、日付、時刻、IP(Internet・Protocol)アドレス、小数点数などがある。例えば日付は、最上位から年、月、日という3つの階層からなる階層構造をとるものであり、よく使用される区切り文字としてはスラッシュ「/」がある。また、属性値が日付の場合、各階層はいずれも正の整数値で、月の階層の値域は1〜12、日の階層の値域は1〜31(又は、28、29、30)である。例えば、属性値が日付や時刻であれば、属性範囲条件入力部101は、属性値の書式として、属性値が日付や時刻であることを示す属性範囲条件データを入力することとなる。また、例えば、属性値がIPアドレスであれば、属性範囲条件入力部101は、属性値の書式として、属性値がIPアドレスであることを示す属性範囲条件データを入力することとなる。
In the present embodiment, the user of the regular
ステップS102において、演算部102は、属性値全体について、各階層を1桁として、第1の値と第2の値とを演算する。
In step S <b> 102, the
ステップS103において、正規表現生成部104は、第1の値と第2の値との間に属性値が存在する場合には、属性値全体について、各階層を1桁として、中位領域データを生成する。その後さらに、その中位領域データを各階層を正規表現で表すものにCPU911で変換する。また、ステップS104において、正規表現生成部104は、属性値全体について、各階層を1桁として、下位領域データを生成する。その後に、その下位領域データを各階層を正規表現で表すものにCPU911で変換する。同様に、ステップS105において、正規表現生成部104は、属性値全体について、各階層を1桁として、上位領域データを生成する。その後に、その上位領域データを各階層を正規表現で表すものにCPU911で変換する。
In step S103, when there is an attribute value between the first value and the second value, the regular
このように、本実施の形態において、正規表現生成装置100は、複数の値と区切り文字とから構成される階層を持った属性値の上限値と下限値とを指定する属性範囲条件を正規表現に変換する検索条件生成方式、又は、この方式を計算機上で実行するための検索条件生成プログラムを実装するものである。この方式では、最上位の階層から最下位の階層に向かって順番に、それぞれの値を実施の形態1や3と同様の手順に従って正規表現に変換する。
As described above, in the present embodiment, the regular
上記検索条件生成方式では、例えば、日付の属性範囲条件を正規表現に変換する。また、例えば、時刻の属性範囲条件を正規表現に変換する。また、例えば、IPアドレスの属性範囲条件を正規表現に変換する。 In the search condition generation method, for example, the date attribute range condition is converted into a regular expression. Also, for example, the time attribute range condition is converted into a regular expression. For example, the attribute range condition of the IP address is converted into a regular expression.
以下、実施の形態1や3と同様に、正規表現を生成する処理の流れを、例を交えて説明する。ここで説明するのは、属性範囲条件の下限値Aと上限値Bに対して、A≦X≦Bを満たす値X(下限値Aから上限値Bまでの属性値X)の文字列表現を受理する正規表現の生成処理の流れである。ここでは、区切り文字を<d1><d2>...として、属性値を次のように表すものとする。
下限値A:A1<d1>A2<d2>...<dn−1>An
上限値B:B1<d1>B2<d2>...<dn−1>Bn
ここで、Ai、Bi(1≦i≦n)は各階層の1桁以上の属性値を表し、その値域はVi min≦Ai、Bi≦Vi maxとする。
Hereinafter, similarly to
Lower limit A: A 1 <d 1 > A 2 <d 2 >. . . <D n-1 > A n
Upper limit B: B 1 <d 1 > B 2 <d 2 >. . . <D n-1 > B n
Here, A i and B i (1 ≦ i ≦ n) represent attribute values of one or more digits in each layer, and their value ranges are V i min ≦ A i and B i ≦ V i max .
ステップS102では、演算部102は、各階層を1桁の値と見なして全体を下位、中位、上位の各領域に分割する。このときの分割手順は、図5又は図10に示したのと同様の手順によって行う。即ち、属性範囲条件A〜Bを以下のように分割する。階層構造のある属性では、第2階層以下(即ち、最上位層以外の階層)の属性値が実施の形態1の形式の属性値の場合、Vi min、Vi maxが定義されていると考えられる。それ以外の場合には、Aiと桁数が同じ値の範囲で、最小値、最大値を考えればよい。
下位領域:A1<d1>A2<d2>...<dn−1>An〜A1<d1>V2 max<d2>...<dn−1>Vn max
中位領域:(A1+1)<d1>V2 min<d2>...<dn−1>Vn min〜(B1−1)<d1>V2 max<d2>...<dn−1>Vn max
上位領域:B1<d1>V2 min<d2>...<dn−1>Vn min〜B1<d1>B2<d2>...<dn−1>Bn
In step S102, the
Lower region: A 1 <d 1 > A 2 <d 2 >. . . <D n-1 > A n to A 1 <d 1 > V 2 max <d 2 >. . . <D n-1 > V n max
Middle region: (A 1 +1) <d 1 > V 2 min <d 2 >. . . <D n-1 > V n min ~ (B 1 -1) <d 1 > V 2 max <d 2 >. . . <D n-1 > V n max
Upper region: B 1 <d 1 > V 2 min <d 2 >. . . <D n-1 > V n min to B 1 <d 1 > B 2 <d 2 >. . . <D n-1 > B n
ステップS103において、正規表現生成部104は、中位領域について、階層ごとに正規表現を生成することにより、そのまま正規表現を生成することができる。
中位領域の正規表現:“<(A1+1)〜(B1−1)の正規表現><d1><V2 min〜V2 maxの正規表現><d2>...<dn−1><Vn min〜Vn maxの正規表現>”
正規表現生成部104は、各階層の正規表現の生成方法として、それぞれの属性値の形式に従って、実施の形態1や3に示したものと同様の手順を用いることができる。つまり、正規表現生成部104は、各階層について、演算部102が行う処理と同様に、下位、中位、上位領域に値の範囲を分割し、各領域に関して正規表現を生成し、正規表現結合部105が行う処理と同様に、生成した正規表現を以下の形式で書き出す。
正規表現:“(<i階層の下位領域の正規表現>|<i階層の中位領域の正規表現>|<i階層の上位領域の正規表現>)”
これにより、正規表現生成部104は、各階層を1桁として扱っていた中位領域の正規表現を、各階層もそれぞれに対応する正規表現を含んだ正規表現に変換することができる。
In step S <b> 103, the regular
Regular expression in the middle region: “<Regular expression of (A 1 +1) to (B 1 −1)><Regular expression of d 1 ><V 2 min to V 2 max ><d 2 > ... <d n-1 ><regular expression of V n min to V n max > ”
The regular
Regular expression: “(<regular expression in the lower area of the i hierarchy> || <regular expression in the middle area of the i hierarchy> || regular expression in the upper area of the i hierarchy>)”
As a result, the regular
下位領域に関しては、ステップS104において、正規表現生成部104が、第2階層以下を、上記の手順と同様にして下位、中位(下位、上位と考えることもできる)の各領域に分割する。上位領域がない(中位領域がないと考えることもできる)のは、元の下位領域の上限値の第2階層の値が、その属性の値域の最大値V2 maxになっているためである。これにより、下位領域は、さらに下位領域と中位領域に分割できる。
下位領域:A1<d1>A2<d2>...<dn−1>An〜A1<d1>A2<d2>V3 max<d3>...<dn−1>Vn max
中位領域:A1<d1>(A2+1)<d2>V3 min<d3>...<dn−1>Vn min〜A1<d1>V2 max<d2>...<dn−1>Vn max
続いて、正規表現生成部104は、ステップS103と同様の手順で中位領域の正規表現を生成するとともに、下位領域の次の階層以下をさらに分割する。このようにして、下位、中位領域への分割と中位領域の正規表現の生成とを最下位の階層まで繰り返すことにより、正規表現生成部104は、各階層を1桁として扱っていた下位領域の正規表現を、各階層もそれぞれに対応する正規表現を含んだ正規表現に変換することができる。
Regarding the lower region, in step S104, the regular
Lower region: A 1 <d 1 > A 2 <d 2 >. . . <D n-1 > A n to A 1 <d 1 > A 2 <d 2 > V 3 max <d 3 >. . . <D n-1 > V n max
Middle region: A 1 <d 1 > (A 2 +1) <d 2 > V 3 min <d 3 >. . . <D n-1 > V n min to A 1 <d 1 > V 2 max <d 2 >. . . <D n-1 > V n max
Subsequently, the regular
上位領域に関しても、ステップS105において、正規表現生成部104が、同様に第2階層以下を中位、上位(下位、上位と考えることもできる)の各領域に分割する。下位領域がない(中位領域がないと考えることもできる)のは、元の上位領域の下限値の第2階層の値が、その属性の値域の最小値V2 minになっているためである。これにより、上位領域は、さらに中位領域と上位領域に分割できる。
中位領域:B1<d1>V2 min<d2>...<dn−1>Vn min〜B1<d1>(B2−1)<d2>V3 max<d3>...<dn−1>Vn max
上位領域:B1<d1>B2<d2>V3 min<d3>...<dn−1>Vn min〜B1<d1>B2<d2>...<dn−1>Bn
続いて、正規表現生成部104は、ステップS103と同様の手順で中位領域の正規表現を生成するとともに、上位領域の次の階層以下を同様に分割する。このようにして、中位、上位領域への分割と中位領域の正規表現の生成とを最下位の階層まで繰り返すことにより、正規表現生成部104は、各階層を1桁として扱っていた上位領域の正規表現を、各階層もそれぞれに対応する正規表現を含んだ正規表現に変換することができる。
Regarding the upper area, in step S105, the regular
Middle region: B 1 <d 1 > V 2 min <d 2 >. . . <D n-1 > V n min to B 1 <d 1 > (B 2 -1) <d 2 > V 3 max <d 3 >. . . <D n-1 > V n max
Upper region: B 1 <d 1 > B 2 <d 2 > V 3 min <d 3 >. . . <D n-1 > V n min to B 1 <d 1 > B 2 <d 2 >. . . <D n-1 > B n
Subsequently, the regular
ステップS104及びS105の正規表現生成処理において、第k階層以下(2≦k≦n)の全階層の値が、全ての値の範囲をとる場合、即ち、以下の場合には値の範囲を分割する必要はない。
下限値:A1<d1>...<dk−2>Ak−1<dk−1>Vk min<dk>...<dn−1>Vn min
上限値:B1<d1>...<dk−2>Bk−1<dk−1>Vk max<dk>...<dn−1>Vn max
そして、正規表現生成部104は、k−1桁目以下に対する正規表現を、以下のようにして生成することができる。
正規表現:“[Ak−1−Bk−1]<dk−1><Vk min〜Vk maxの正規表現><dk>...<dn−1><Vn min〜Vn maxの正規表現>”
In the regular expression generation processing in steps S104 and S105, when the values of all layers below the k-th layer (2 ≦ k ≦ n) take the range of all values, that is, the value range is divided in the following cases do not have to.
Lower limit: A 1 <d 1 >. . . <D k-2> A k -1 <d k-1> V k min <d k>. . . <D n-1 > V n min
Upper limit value: B 1 <d 1 >. . . <D k-2 > B k-1 <d k-1 > V k max <d k >. . . <D n-1 > V n max
And the regular expression production |
Regular expression: "[A k-1 -B k-1 ] <d k-1 ><regular expression of V k min to V k max ><d k > ... <d n-1 ><V n min Regular expression of ~ V n max > ”
ステップS106において、正規表現結合部105は、ステップS103〜S105で個別に生成された下位、中位、上位領域の正規表現を結合して、以下のように属性範囲条件に対応する正規表現を生成する。
“<下位領域の正規表現>|<中位領域の正規表現>|<上位領域の正規表現>”
中位領域がない場合に生成される正規表現は以下のような形式となる。
“<下位領域の正規表現>|<上位領域の正規表現>”
In step S106, the regular
"<Regular expression in lower region> | <Regular expression in middle region> | <Regular expression in upper region>"
The regular expression generated when there is no middle-level area has the following format.
"<Regular expression in lower area> | <Regular expression in upper area>"
上記の方式を日付に適用した場合の具体例を示す。典型的な日付の形式として、ここでは年月日がスラッシュ「/」で区切られているものとする。 A specific example of applying the above method to a date is shown. As a typical date format, it is assumed here that the date is separated by a slash “/”.
(例4−1)属性範囲条件:1996/11/15〜2006/9/20 (Example 4-1) Attribute range condition: 1996/11/15 to 2006/9/20
属性範囲条件入力部101は、属性範囲条件の入力として、下限値、上限値の他に、区切り文字「/」、属性値の種類(日付)、年月日の順序などを指定する。ここで、実施の形態2と同様に、条件記憶部107が、正規表現を生成する処理のために参照可能な記憶装置151内の記憶領域の一部に、複数種類の日付の形式を記憶しておき、識別子入力部108が識別子を指定することにより、自動的に対応する日付の形式を選択できるようにしてもよい。この場合、属性範囲条件入力部101は、条件記憶部107により記憶装置151に予め記憶されている複数の属性範囲条件データの中から、識別子入力部108により入力された識別子に対応付けて記憶された属性範囲条件データを読み出して入力する。そして、この属性範囲条件データに基づいて、正規表現が生成される。あるいは、演算部102や正規表現生成部104などが、属性範囲条件入力部101により指定された下限値、上限値から日付の形式を自動的に識別するようにしてもよい。例えば、下限値が「A3年A2月A1日」(A3、A2、A1はいずれも数値)と指定されたならば、区切り文字は「年」「月」「日」で、左から順に上位の階層であることを容易に認識することができる。ここで、日付を、あたかも0≦A3、1≦A2≦12、1≦A1≦31という値域の属性要素からなる3桁の属性A3A2A1であるかのように扱うこともできる。
The attribute range
上記の手順に従うと、ステップS102において、演算部102は、この例の属性範囲を以下の通り下位、中位、上位領域に分割できる。
下位領域:1996/11/15〜1996/12/31
中位領域:1997/1/1〜2005/12/31
上位領域:2006/1/1〜2006/9/20
According to the above procedure, in step S102, the
Lower region: 1996/11/15 to 1996/12/31
Middle region: 1997/1/1 to 2005/12/31
Upper area: 2006/1/1 to 2006/9/20
ステップS103において、正規表現生成部104は、中位領域の正規表現を以下の通りに生成する。
中位領域の正規表現:“<1997〜2005の正規表現>/<1〜12の正規表現>/<1〜31の正規表現>“
In step S103, the regular
Regular expression of middle region: “<regular expression of 1997-2005> / <regular expression of 1-12> / <regular expression of 1-31>”
ステップS104において、正規表現生成部104は、下位領域(1996/11/15〜1996/12/31)を、さらに下位と中位領域とに分割できる。
下位領域:1996/11/15〜1996/11/31
中位領域:1996/12/1〜1996/12/31
これより、元の属性範囲の下位領域の正規表現は、以下の通り生成される。
下位領域(1996/11/15〜1996/12/31)の正規表現:“1996/(11/<15〜31の正規表現>|12/<1〜31の正規表現>)”
In step S104, the regular
Lower region: 1996/11/15 to 1996/11/31
Middle region: 1996/12/1 to 1996/12/31
Thus, the regular expression of the lower area of the original attribute range is generated as follows.
Regular expression of lower region (1996/11/15 to 1996/12/31): “1996 / (11 / <regular expression of 15 to 31> | 12 / <regular expression of 1 to 31>)”
ステップS105において、正規表現生成部104は、上位領域(2006/1/1〜2006/9/20)を、さらに中位と上位領域とに分割できる。
中位領域:2006/1/1〜2006/8/31
上位領域:2006/9/1〜2006/9/20
これより、元の属性範囲の上位領域の正規表現は、以下の通り生成される。
上位領域(2006/1/1〜2006/9/20)の正規表現:“2006(<1〜8の正規表現>/<1〜31の正規表現>|9/<1〜20の正規表現>)”
In step S105, the regular
Middle region: 2006/1/1 to 2006/8/31
Upper area: 2006/9/1 to 2006/9/20
Thus, the regular expression of the upper area of the original attribute range is generated as follows.
Regular expression of upper region (2006/1/1 to 2006/9/20): “2006 (<regular expression of 1 to 8> / <regular expression of 1 to 31 >> | 9 / <regular expression of 1 to 20> ) ”
ステップS106において、正規表現結合部105は、上記属性範囲条件の正規表現を以下のように構成することとなる。
正規表現:“(1996/(11/<15〜31の正規表現>|12/<1〜31の正規表現>))|(<1997〜2005の正規表現>/<1〜12の正規表現>/<1〜31の正規表現>)|(2006(<1〜8の正規表現>/<1〜31の正規表現>|9/<1〜20の正規表現>))”
これを展開すると、次のような正規表現が得られる。
正規表現:“(1996/(11/(1[5−9]|2[0−9]|3[0−1])|12/([0−9]|[1−2][0−9]|3[0−1])))|((199[7−9]|200[0−5])/([1−9]|1[0−2])/([0−9]|[1−2][0−9]|3[0−1]))|(2006/([1−8]/([0−9]|[1−2][0−9]|3[0−1])|9/([1−9]|1[0−9]|20)))”
In step S106, the regular
Regular expression: "((1996 / (11 / <regular expression of 15 to 31 >> | 12 / <regular expression of 1 to 31>)) | (<regular expression of 1997 to 2005> / <regular expression of 1 to 12>) / <Regular expression of 1-31>) | (2006 (<Regular expression of 1-8> / <Regular expression of 1-31> | 9 / <Regular expression of 1-20>)) ”
If this is expanded, the following regular expression is obtained.
Regular expression: "(1996 / (11 / (1 [5-9] | 2 [0-9] | 3 [0-1]) | 12 / ([0-9] | [1-2] [0- 9] | 3 [0-1]))) | ((199 [7-9] | 200 [0-5]) / ([1-9] | 1 [0-2]) / ([0-9 ] | [1-2] [0-9] | 3 [0-1])) | (2006 / ([1-8] / ([0-9] | [1-2] [0-9] | 3 [0-1]) | 9 / ([1-9] | 1 [0-9] | 20))) "
上記の日付の例では、「11/31」という本来存在しない日付まで検索してしまう。ここで、厳密に日の値域を処理したいのであれば、以下の例のように日の値域が異なるグループごとに正規表現を分けて生成すればよい。
修正前:“<1〜12の正規表現>/<1〜31の正規表現>”
修正後:“(1|3|5|7|8|10|12)/<1〜31の範囲の正規表現>|(4|6|9|11)/<1〜30の範囲の正規表現>|2/<1〜28の範囲の正規表現>”
In the example of the above date, the search is performed up to a date “11/31” which does not exist originally. Here, if it is desired to strictly process the day value range, a regular expression may be generated separately for each group having different day value ranges as in the following example.
Before modification: “<Regular expression of 1 to 12> / <Regular expression of 1 to 31>”
After correction: “(1 | 3 | 5 | 7 | 8 | 10 | 12) / <regular expression in the range of 1-31> | (4 | 6 | 9 | 11) / <regular expression in the range of 1-30 > | 2 / <regular expression in the range 1-28>"
これまでの説明では、属性値の下限値A、上限値Bともに指定されている場合について示してきた。ここでは、上限値Bの指定がない場合や上限値が「無限大」と指定された場合について説明する。属性のデータ型として最大値B´が存在する場合は、正規表現結合部105は下限値Aから上限値B´までの正規表現を生成すればよい。属性のデータ型として最大値がない場合には、第1階層の値に着目して処理するとよい。
In the description so far, the case where both the lower limit value A and the upper limit value B of the attribute value are specified has been shown. Here, a case where the upper limit value B is not specified or a case where the upper limit value is specified as “infinity” will be described. When the maximum value B ′ exists as the attribute data type, the regular
まず、正規表現結合部105は、下限値Aの第1階層の値と同じ桁数mの属性値の最大値を第1階層に持つような属性値の中で値が最も大きいもの、即ち、第2階層以下の値が全てVi max(2≦i≦n)であるような値を上限値として正規表現を生成する。例えば、「2006/9/20」以降の日付を検索するための正規表現であれば、「2006/9/20」〜「9999/12/31」の属性範囲条件に対して正規表現を生成する。さらに、第1階層の値がn+1桁以上の任意の属性値を検索する正規表現を追加する。上記の例であれば、5桁以上の年を表現する正規表現を“[1−9][0−9]{4,}”と書くことができる。
First, the regular
下限値Aの指定がない場合や下限値が「無限小」と指定された場合について説明する。まず、属性のデータ型として最小値A´があるならば、正規表現結合部105は下限値A´と上限値Bについて正規表現を生成するようにすればよい。それ以外の場合は、第1階層以下の値が最小値Vi min(1≦i≦n)であるような属性値を下限値として、正規表現を生成すればよい。
A case where the lower limit value A is not specified or a case where the lower limit value is specified as “infinitesimal” will be described. First, if there is a minimum value A ′ as an attribute data type, the regular
階層構造を持つ属性の属性範囲条件による検索には、次のような応用も考えられる。 The following applications are also conceivable for the search based on the attribute range condition of attributes having a hierarchical structure.
(例4−2)属性範囲条件:2006年9月〜2006年12月の平日
上記の条件を満たす日付を表す文字列を照合するための正規表現の生成手順を示す。上記の条件は、次の点でこれまで説明した属性範囲条件と異なる。
(1)「月」と「曜日」の2階層に範囲が設定されている。先に示した日付の属性範囲条件の例は、「年」と「月」に範囲が設定されているが、値としての実体は連続値である。
(2)第3階層の「日」に明示的な範囲条件が設定されていない。
(3)「日」と「曜日」は連動して変化する。厳密には上下の階層関係にない値である。
ここで、簡単のためにここでの日付の属性値は、左から順に「年」「月」「日」「曜日」が並んでおり、「年」「月」「日」間の区切り文字はスラッシュ「/」、「日」と「曜日」間の区切り文字は空白文字(厳密には、全角空白文字又は半角空白文字いずれか一方)であるとする。また、「曜日」の値域は、V4 min=“SUN”、V4 max=“SAT”という値を取るものとする。この属性範囲条件の第3階層は明示的に設定されていないが、V3 min〜V3 maxの値をとると考えてよい。このような属性範囲条件は以下のように考えられる。
属性範囲条件1:2006/9/1〜2006/12/31
属性範囲条件2:MON〜FRI
(Example 4-2) Attribute range condition: Weekdays from September 2006 to December 2006 A procedure for generating a regular expression for matching a character string representing a date satisfying the above conditions is shown. The above conditions differ from the attribute range conditions described so far in the following respects.
(1) Ranges are set in two layers of “month” and “day of the week”. In the example of the date attribute range condition shown above, ranges are set for “year” and “month”, but the substance as a value is a continuous value.
(2) No explicit range condition is set for “day” in the third hierarchy.
(3) “Day” and “Day of the week” change in conjunction. Strictly speaking, it is a value that is not in a hierarchical relationship.
Here, for the sake of simplicity, the attribute values of the date here are "year", "month", "day", and "day of the week" in order from the left. Assume that the delimiter between the slash “/” and “day” and “day of the week” is a blank character (strictly speaking, either a full-width space character or a half-width space character). In addition, the value range of “day of the week” is assumed to have values of V 4 min = “SUN” and V 4 max = “SAT”. Although the third hierarchy of this attribute range condition is not explicitly set, it may be considered that the value ranges from V 3 min to V 3 max . Such an attribute range condition is considered as follows.
Attribute range condition 1: 2006/9/1 to 2006/12/31
Attribute range condition 2: MON to FRI
あとは、先に説明した日付の属性範囲条件の正規表現を生成する手順に従って、正規表現結合部105が属性範囲条件1の正規表現を生成し、さらに区切り文字に続けて属性範囲条件2の正規表現“(MON|TUE|WED|THU|FRI)”を結合すればよい。これにより最終的に生成される正規表現は以下のようになる。
正規表現:“(2006/(9|1[0−2])/([1−9]|[12][0−9]|3[01])) (MON|TUE|WED|THU|FRI)”
After that, the regular
Regular expression: “(2006 / (9 | 1 [0-2]) / ([1-9] | [12] [0-9] | 3 [01])) (MON | TUE | WED | THU | FRI ) ”
次に、上記の方式を時刻に適用した場合の具体例を示す。ここでは、時分秒の各階層がコロン「:」で区切られ、時間は24時間表記であるものとする。 Next, a specific example when the above method is applied to time will be shown. Here, it is assumed that each level of hour, minute and second is separated by a colon “:” and the time is expressed in 24 hours.
(例4−3)属性範囲条件:8:45:00〜17:15:00 (Example 4-3) Attribute range condition: 8:45:00 to 17:15:00
ステップS102において、演算部102は、この属性範囲条件を以下のように下位、中位、上位領域に分割できる。
下位領域:8:45:00〜8:59:59
中位領域:9:00:00〜16:59:59
上位領域:17:00:00〜17:15:00
In step S102, the
Lower area: 8:45:00 to 8:59:59
Middle region: 9:00:00 to 16:59:59
Upper area: 17:00: 00 to 17: 15:00
ここから、正規表現生成部104及び正規表現結合部105が同様に処理して、以下の通り正規表現を生成することができる。
正規表現:“(8:(4[5−9]|5[0−9]):(0[0−9]|[1−4][0−9]|5[0−9])|(9|1[0−6]):([0−5][0−9]):(0[0−9]|[1−4][0−9]|5[0−9])|17:((0[0−9]|1[0−4]):(0[0−9]|[1−4][0−9]|5[0−9])|15:00))”
From here, the regular
Regular expression: “(8: (4 [5-9] | 5 [0-9]) :( 0 [0-9] | [1-4] [0-9] | 5 [0-9]) | (9 | 1 [0-6]): ([0-5] [0-9]) :( 0 [0-9] | [1-4] [0-9] | 5 [0-9]) | 17: ((0 [0-9] | 1 [0-4]) :( 0 [0-9] | [1-4] [0-9] | 5 [0-9]) | 15: 00 )) ”
上記の例では、秒の値の範囲である「00〜59」に対応する正規表現を、実施の形態1に示した手順で生成するものとして、“0[0−9]|[1−4][0−9]|5[0−9]”としたが、この正規表現は“[0−5][0−9]”のようにより簡略な表記にすることもできる。時刻の中の属性で、分や秒の「00〜59」のように出現頻度の高いパターンに対しては、定型の正規表現を磁気ディスク装置920に記憶しておき、必要に応じて読み出して使用することにより、正規表現の生成処理をより簡略化することができる。このような出現頻度の高いパターンの例としては、日付の「(0)1〜12」、「(0)1〜31」、時刻の「0〜12」、「0〜24」、「00〜59」、IPアドレスの「0〜255」など、「Vi min〜Vi max」となるパターンが挙げられる。
In the above example, it is assumed that the regular expression corresponding to “00 to 59” that is the range of the second value is generated by the procedure shown in the first embodiment, and “0 [0-9] | [1-4 ] [0-9] | 5 [0-9] ", but this regular expression can be expressed in a simpler form such as" [0-5] [0-9] ". For patterns with a high frequency of appearance such as minutes and seconds of “00 to 59” in the time, a regular expression is stored in the
以下のように、時刻が12時間表記の場合は、午前と午後とに分けて考えればよい。 As shown below, when the time is expressed in 12 hours, it may be divided into morning and afternoon.
(例4−4)属性範囲条件:8:45:00AM〜5:15:00PM
このような属性範囲条件は以下のように考えられる。
属性範囲条件1:8:45:00AM〜11:59:59AM
属性範囲条件2:0:00:00PM〜5:15:00PM
このように午前と午後とで個別に正規表現を生成した後で、正規表現結合部105が以下の通り正規表現を結合すればよい。
正規表現:“<属性範囲条件1の正規表現>|<属性範囲条件2の正規表現>”
(Example 4-4) Attribute range condition: 8:45:00 AM to 5:15:00 PM
Such an attribute range condition is considered as follows.
Attribute range condition 1: 8: 45: 00 AM to 11:59:59 AM
Attribute range condition 2:00:00 PM to 5:15:00 PM
After the regular expressions are generated individually in the morning and afternoon in this way, the regular
Regular expression: “<Regular expression of
IPアドレスの場合は、4個の正の整数が区切り文字であるピリオド「.」で区切られており、左から順に上位の階層となっている。また、各階層の数値の値域は0〜255である。また、IPv6のIPアドレスは、8個の16進数値が区切り文字であるコロン「:」で区切られている。いずれの場合も、上位の階層から下位の階層に向かって領域を分割する手順を適用し、各階層の値については実施の形態1の手順を適用することにより、同様に正規表現を生成することができる。各階層は、0以上の整数、即ち、実施の形態1と同様の形式の属性値として処理することができる。 In the case of an IP address, four positive integers are separated by a period “.”, Which is a delimiter, and the upper layers are arranged in order from the left. Moreover, the numerical value range of each hierarchy is 0-255. Further, the IPv6 IP address is delimited by a colon “:” having eight hexadecimal values as delimiters. In either case, a regular expression is generated in the same manner by applying a procedure for dividing an area from an upper hierarchy toward a lower hierarchy, and applying the procedure of the first embodiment for each hierarchy value. Can do. Each hierarchy can be processed as an integer value of 0 or more, that is, an attribute value in the same format as in the first embodiment.
(例4−5)属性範囲条件:10.0.1.1〜10.2.100.254 (Example 4-5) Attribute range condition: 10.0.1.1 to 10.2.100.254
ステップS102において、演算部102は、この属性範囲条件を以下のように下位、中位、上位領域に分割できる。
下位領域:10.0.1.1〜10.0.255.255
中位領域:10.1.0.0〜10.1.255.255
上位領域:10.2.0.0〜10.2.100.254
In step S102, the
Lower region: 10.0.1.1 to 10.0.255.255
Middle region: 10.1.0.0-10.1.25.255
Upper area: 10.2.0.0.0 to 10.2.10.254
ここから、同様に下位の階層に向かって処理を行う。即ち、ステップS104において、正規表現生成部104は、下位領域を、さらに以下のように分割できる。
下位領域:10.0.1.1〜10.0.1.255
中位領域:10.0.2.0〜10.0.255.255
From here, the processing is similarly performed toward the lower hierarchy. That is, in step S104, the regular
Lower region: 10.0.1.1 to 10.0.1.255
Middle region: 10.0.2.0 to 10.0.255.255
ステップS105において、正規表現生成部104は、上位領域を、さらに以下のように分割できる。
中位領域:10.2.0.0〜10.2.0.99.255
上位領域:10.2.100.0〜10.2.100.254
In step S105, the regular
Middle region: 10.2.0.0-10.2.0.99.255
Upper region: 10.2.100.0-10.2.210.254
最終的に、ステップS106において、正規表現結合部105は、以下の通り正規表現を生成することができる。
正規表現:“10¥.((0¥.(1¥.([1−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9]))|([2−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9]))¥.([0−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9]))))|(1¥.([0−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9]))¥.([0−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9])))|(2¥.(([0−9]|[1−9][0−9])¥.([0−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−5]|2[0−4][0−9]))|100¥.([0−9]|[1−9][0−9]|1[0−9][0−9]|(25[0−4]|2[0−4][0−9])))))”
Finally, in step S106, the regular
Regular expression: “10 ¥. ((0 ¥. (1 ¥. ([1-9] | [1-9] [0-9] | 1 [0-9] [0-9] | (25 [0 -5] | 2 [0-4] [0-9])) | ([2-9] | [1-9] [0-9] | 1 [0-9] [0-9] | (25 [0-5] | 2 [0-4] [0-9])) ¥. ([0-9] | [1-9] [0-9] | 1 [0-9] [0-9] | (25 [0-5] | 2 [0-4] [0-9])))) | (1 ¥. ([0-9] | [1-9] [0-9] | 1 [0 -9] [0-9] | (25 [0-5] | 2 [0-4] [0-9])) ¥ ([0-9] | [1-9] [0-9] | 1 [0-9] [0-9] | (25 [0-5] | 2 [0-4] [0-9]))) | (2 ¥. (([0-9] | [1- 9] [0-9]) ¥. ([0-9] | [1-9] [0- ] | 1 [0-9] [0-9] | (25 [0-5] | 2 [0-4] [0-9])) | 100 ¥. ([0-9] | [1-9 ] [0-9] | 1 [0-9] [0-9] | (25 [0-4] | 2 [0-4] [0-9]))))) "
小数は、整数部と小数部がピリオド「.」で区切られた数値である。正規表現の生成手順は、上位の階層である整数部、下位の階層である小数部の順に領域を分割する手順を適用し、整数部の値については実施の形態1の手順を適用し、小数部の値については実施の形態3の手順を適用することにより、同様に正規表現を生成することができる。 The decimal is a numerical value in which an integer part and a decimal part are separated by a period “.”. The regular expression generation procedure applies the procedure of dividing the region in the order of the integer part that is the upper hierarchy and the decimal part that is the lower hierarchy, and applies the procedure of the first embodiment for the value of the integer part. By applying the procedure of the third embodiment for the value of the part, a regular expression can be similarly generated.
(例4−6)属性範囲条件:1.4142〜6.63 (Example 4-6) Attribute range condition: 1.4142 to 6.63
ステップS102において、演算部102は、この属性範囲条件を以下のように下位、中位、上位領域に分割できる。ここで、第2階層は実施の形態3の形式の属性値なので、その最小値、最大値は桁数が同じ値の範囲で考える。即ち、下限値の第2階層の値が4桁なので、演算部102は、下位領域の上限値として4桁の数値の最大値を選択する。また、上限値の第2階層の値が2桁なので、演算部102は、上位領域の下限値として2桁の数値の最小値を選択する。
下位領域:1.4142〜1.9999
中位領域:2.00〜5.99
上位領域:6.00〜6.63
In step S102, the
Lower region: 1.4142 to 1.9999
Middle region: 2.00 to 5.99
Upper region: 6.00 to 6.63
最終的に、ステップS106において、正規表現結合部105は、以下の正規表現を生成することができる。
正規表現:“(1¥.((414[2−9]|41[5−9]|4[2−9])|([5−9])))|([2−5]¥.[0−9])|(6¥.(([0−5])|(6[0−3])))”
Finally, in step S106, the regular
Regular expression: “(1 ¥. ((414 [2-9] | 41 [5-9] | 4 [2-9]) | ([5-9]))) | ([2-5] ¥. [0-9]) | (6 ¥. (([0-5]) | (6 [0-3]))) "
なお、区切り文字が正規表現で使用されるメタキャラクタ(正規表現において特別な意味を持つ文字)の場合には、その区切り文字の直前にエスケープ文字(バックスラッシュ、又は、日本語Windows(登録商標)の環境では主に「¥」が使用される)を挿入しなければならない。そのようなメタキャラクタとしては、「|」、「?」、「*」、「+」、「.」、「(」、「)」、「{」、「}」、「[」、「]」、「¥」、「^」、「$」、「<」、「>」がある。ただし、メタキャラクタの種類は、正規表現の処理系によって異なる場合がある。 When the delimiter is a metacharacter (character having a special meaning in the regular expression) used in the regular expression, an escape character (backslash or Japanese Windows (registered trademark)) immediately before the delimiter. In this environment, “¥” is mainly used). Such metacharacters include “|”, “?”, “*”, “+”, “.”, “(”, “)”, “{”, “}”, “[”, “] ”,“ ¥ ”,“ ^ ”,“ $ ”,“ <”,“> ”. However, the type of metacharacter may differ depending on the regular expression processing system.
以上のように、本実施の形態に係る正規表現生成装置100によれば、複数の属性値と区切り記号から構成される階層構造を持った属性の下限値、上限値、書式などを指定した属性範囲条件から、その下限値から上限値までの範囲に含まれる属性値を表現する文字列を照合するための正規表現を自動的に生成することができる。これにより、従来は正確に記述することが困難であった複雑な属性範囲条件を照合する正規表現を、特別な知識も試行錯誤も必要なく、容易に短時間で得ることができる。
As described above, according to the regular
実施の形態5.
本実施の形態について、主に実施の形態1との差異を説明する。
Embodiment 5. FIG.
In the present embodiment, differences from the first embodiment will be mainly described.
本実施の形態は、既定の構文規則や書式に従って記述されたテキストデータの、特定の範囲に含まれる文字列を検索するための正規表現を生成する処理の流れを説明するものである。ここでは、従来のように検索対象として指定される特定の文字列だけではなく、下限値から上限値までの特定の範囲に含まれる属性値を表現する文字列が検索対象となる。 In the present embodiment, a flow of processing for generating a regular expression for searching a character string included in a specific range of text data described according to a predetermined syntax rule or format will be described. Here, not only a specific character string designated as a search target as in the prior art, but also a character string expressing an attribute value included in a specific range from a lower limit value to an upper limit value is a search target.
図13は、本実施の形態に係る正規表現生成装置100の構成を示すブロック図である。
FIG. 13 is a block diagram showing a configuration of regular
図13において、正規表現生成装置100は、実施の形態1で説明した図1に示したものに加え、テキスト範囲条件入力部109を備える。正規表現生成装置100は、実施の形態2と同様に、さらに、条件記憶部107、識別子入力部108を備えていてもよい。
In FIG. 13, the regular
テキスト範囲条件入力部109は、テキスト範囲条件データを入力装置153から入力する。テキスト範囲条件データは、所定の構文規則に従って記述されたテキストの特定の領域を示すテキスト範囲条件のデータである。テキスト範囲条件によって、テキスト中の特定の範囲が指定される。例えば、テキストが電子メールであれば、テキスト範囲条件入力部109は、テキストの特定の領域として、電子メールの特定のヘッダフィールドを示すテキスト範囲条件データを入力することができる。また、例えば、テキストがCSVなどのように区切り文字で複数のフィールドに区切られたものであれば、テキスト範囲条件入力部109は、テキストの特定の領域として、複数のフィールドのいずれかを示すテキスト範囲条件データを入力することができる。
The text range
属性範囲条件入力部101は、属性値の書式として、属性値がテキスト範囲条件入力部109により入力されたテキスト範囲条件データが示す領域に含まれることを示す属性範囲条件データを入力する。
The attribute range
正規表現生成部104は、さらに、テキスト範囲条件入力部109により入力されたテキスト範囲条件データが示す領域を正規表現で表すテキスト領域データ(以下、単に「正規表現」、又は「範囲」などという場合がある)を処理装置152で生成する。
The regular
正規表現結合部105は、属性範囲条件入力部101により入力された属性範囲条件データが示す書式に基づいて、正規表現生成部104により生成された下位領域データと上位領域データと中位領域データとテキスト領域データとを結合して、属性値を含む前記テキストの特定の領域を正規表現で表す正規表現データを生成する。
Based on the format indicated by the attribute range condition data input by the attribute range
正規表現生成装置100が、条件記憶部107、識別子入力部108を備えている場合には、条件記憶部107は、複数の属性範囲条件データと複数のテキスト範囲条件データとを予め記憶装置151に記憶しておく。また、条件記憶部107は、各属性範囲条件データと各テキスト範囲条件データとの組み合わせを一意の識別子と対応付けて予め記憶装置151に記憶しておく。識別子入力部108は、任意の識別子を入力装置153から入力する。属性範囲条件入力部101は、識別子入力部108により入力された識別子に対応付けて条件記憶部107により記憶された組み合わせの属性範囲条件データを入力する。同様に、テキスト範囲条件入力部109は、識別子入力部108により入力された識別子に対応付けて条件記憶部107により記憶された組み合わせのテキスト範囲条件データを入力する。
When the regular
図14は、本実施の形態に係る正規表現生成方法を示すフローチャートである。図14のフローチャートに示すフローは、正規表現生成装置100を実現するコンピュータ上で実行されるプログラム(正規表現生成プログラム)の処理手順に相当する。この処理手順において、正規表現生成プログラムは、以下に示す各処理をコンピュータに実行させる。
FIG. 14 is a flowchart showing a regular expression generation method according to the present embodiment. The flow shown in the flowchart of FIG. 14 corresponds to a processing procedure of a program (regular expression generation program) executed on a computer that implements the regular
正規表現生成装置100の利用者がキーボード902やマウス903でテキスト範囲条件データを指定すると、テキスト範囲条件入力部109は、そのテキスト範囲条件データをキーボード902やマウス903から入力する(ステップS901:テキスト範囲条件入力処理)。また、正規表現生成装置100の利用者がキーボード902やマウス903で、そのテキスト範囲条件データが示すテキストの領域に属性値が含まれることを示す属性範囲条件データを指定すると、属性範囲条件入力部101は、その属性範囲条件データをキーボード902やマウス903から入力する(ステップS902:属性範囲条件入力処理)。ステップS902の後は、実施の形態1で説明した図4のフローチャートと同様に、ステップS102の処理が実行される。
When the user of the regular
正規表現生成部104は、ステップS901でテキスト範囲条件入力部109により入力されたテキスト範囲条件データが示すテキストの領域を正規表現で表すテキスト領域データをCPU911で生成する(ステップS903:正規表現生成処理の一部)。ステップS903の後は、実施の形態1で説明した図4のフローチャートと同様に、ステップS103〜S105の処理が実行される。
The regular
正規表現結合部105は、ステップS902で属性範囲条件入力部101により入力された属性範囲条件データが示す書式に基づいて、ステップS903、S103〜S105で正規表現生成部104により生成されたテキスト領域データと下位領域データと上位領域データと中位領域データとをCPU911で結合して(ステップS103で中位領域データが生成されなかった場合には、テキスト領域データと下位領域データと上位領域データのみを結合することになる)、属性値記憶部103により記憶された下限値から上限値までの属性値だけでなく、その属性値を含むテキストの領域を正規表現で表す正規表現データを生成する(ステップS904:正規表現結合処理)。ステップS904の後は、実施の形態1で説明した図4のフローチャートと同様に、ステップS107の処理が実行される。
The regular
このように、本実施の形態において、正規表現生成装置100は、既定の構文規則に従って記述されたテキストデータの特定の領域を選択するテキスト範囲条件と、属性値の値域に含まれる特定の範囲を選択する属性範囲条件を入力とし、これらを、上記領域の中から属性範囲条件に合致する属性値を検出するための正規表現に変換する検索条件生成方式、又は、この方式を計算機上で実行するための検索条件生成プログラムを実装するものである。この方式では、テキスト範囲条件と等価な正規表現と、属性範囲条件と等価な正規表現を生成し、さらに、それらの正規表現を結合する。
As described above, in the present embodiment, the regular
上記検索条件生成方式では、例えば、電子メールの特定のヘッダフィールドを選択するテキスト範囲条件と、属性範囲条件を入力し、それら条件を正規表現に変換する。また、例えば、1行が既定の区切り文字によって複数のフィールドに分割されているテキストデータの特定のフィールドを選択するテキスト範囲条件と、属性範囲条件とを入力し、それら条件を正規表現に変換する。 In the search condition generation method, for example, a text range condition for selecting a specific header field of an e-mail and an attribute range condition are input, and these conditions are converted into regular expressions. In addition, for example, a text range condition for selecting a specific field of text data in which one line is divided into a plurality of fields by a predetermined delimiter and an attribute range condition are input, and these conditions are converted into a regular expression. .
また、正規表現生成装置100は、検索条件から正規表現への変換規則を記憶するための領域を記憶装置151内に設けておいてもよい。この場合、属性範囲条件入力部101、テキスト範囲条件入力部109、識別子入力部108が、属性範囲条件とテキスト範囲条件のいずれか又はその両方と、識別子を入力として受け付ける。上記領域には、条件記憶部107が、例えば、識別子と、属性値の形式によって異なる属性範囲条件を正規表現に変換するための変換規則の組と、識別子と、テキストデータの構文によって異なるテキスト範囲条件を正規表現に変換するための変換規則の組のいずれか、又はその両方を記憶しておく。そして、正規表現生成部104や正規表現結合部105は、入力された識別子と関連付けられた変換規則を上記領域から取り出し、変換規則に従って入力済の属性範囲条件又はテキスト範囲条件を正規表現に変換する。属性範囲条件入力部101、テキスト範囲条件入力部109、識別子入力部108が、属性範囲条件又はテキスト範囲条件を正規表現に変換するための変換規則と識別子との組の入力を受け付け、条件記憶部107が、入力された変換規則と識別子の組を上記領域に記憶するようにしてもよい。
Further, the regular
以下、正規表現を生成する処理の流れを、例を交えて説明する。 Hereinafter, the flow of processing for generating a regular expression will be described with an example.
初めに、既定の構文規則や書式を持つテキストの例を示す。第1の例は、電子メールである。電子メールは、ヘッダフィールドの書式が、RFC(Request・For・Comment)2822などにより定められている。ヘッダフィールドの1項目は、基本的に、フィールド名、フィールドの値、改行(CRLF)から構成されている。第2の例は、CSVファイルである。CSVファイルは、複数のフィールドの値をカンマで区切って記述したテキストファイルで、表形式のデータを表現するために利用されることが多い。類似の形式として、TSV(Tab・Separated・Values)といわれる区切り文字にタブを使用した形式や、区切り文字にスペースを使用した形式などがあるが、いずれも、区切り文字で複数のフィールドに区切られたテキストである。 First, here is an example of text with default syntax rules and formats. The first example is e-mail. In the e-mail, the header field format is defined by RFC (Request For Comment) 2822 or the like. One item of the header field basically includes a field name, a field value, and a line feed (CRLF). The second example is a CSV file. A CSV file is a text file in which values of a plurality of fields are delimited by commas, and is often used to represent tabular data. Similar formats include TSV (Tab / Separated / Values) using a tab as a delimiter and a format using a space as a delimiter, both of which are delimited by multiple fields. Text.
上記のようなテキスト中の、特定の範囲に含まれる文字列を検索するための正規表現は、テキストの書式ごとに異なるテキスト中の範囲を特定するための正規表現と、その範囲内の文字列を検索するための固定キーワードや正規表現とを組み合わせることにより実現することができる。そのために、本実施の形態では、正規表現生成装置100が備える記憶装置151内の参照可能な記憶領域に、書式と範囲を特定するための正規表現を予め記憶しておくことが望ましい。この場合、正規表現生成装置100の入力は、属性範囲条件に示される書式の指定と、テキスト範囲条件に示される検索対象となる範囲の指定と、指定の範囲内を検索する正規表現となる。正規表現生成装置100は、それらの入力がなされると、書式と検索対象とする範囲の指定から、対応する範囲を特定するための正規表現を生成し、さらに生成した正規表現と、範囲内を検索する正規表現とを結合して出力する。
The regular expression to search for the character string included in a specific range in the text as described above is a regular expression for specifying a different range in the text for each text format, and the character string in that range. Can be realized by combining fixed keywords and regular expressions for searching. Therefore, in this embodiment, it is desirable to store in advance a regular expression for specifying a format and a range in a referenceable storage area in the
また、テキスト中の特定の範囲を対象に、実施の形態1〜4に示したような属性範囲条件を指定した検索を行うための正規表現を生成する処理は、テキストの範囲を特定するための正規表現を生成するとともに、実施の形態1〜4に示した手順に従って属性範囲条件に対応する正規表現を生成し、それらを結合することにより実現することができる。
In addition, a process for generating a regular expression for performing a search specifying an attribute range condition as shown in
電子メールの例を示す。電子メールのヘッダフィールドの構文は以下の通りである。
<ヘッダフィールド名>:<属性値><改行(CRLF)>
An example of an email is shown. The syntax of the email header field is:
<Header field name>: <Attribute value><Line feed (CRLF)>
また、複数行にまたがる属性値の場合の構文は以下の通りである。電子メールのヘッダフィールドにおいて、行の先頭が半角空白文字かタブであった場合は、その行は直前の行の続きであることを意味している。
<ヘッダフィールド名>:<属性値><改行(CRLF)>
<半角空白又はタブ><属性値><改行(CRLF)>
・・・・・・
The syntax for attribute values that span multiple lines is as follows. In the header field of an e-mail, if the beginning of a line is a space character or a tab, it means that the line is a continuation of the previous line.
<Header field name>: <Attribute value><Line feed (CRLF)>
<Single-byte space or tab><Attributevalue><Line feed (CRLF)>
・ ・ ・ ・ ・ ・
このとき、電子メールのヘッダフィールドのテキスト範囲条件の正規表現は、以下の形になる。
(1)ヘッダフィールドが1行の場合
正規表現:“(^|¥n)<ヘッダフィールド名>:[^¥n]*<属性値の正規表現>”
(2)ヘッダフィールドが複数行にわたる場合
正規表現:“(^|¥n)<ヘッダフィールド名>:[^¥n]*(<属性値の正規表現>|(¥n(¥s|¥t)+[^¥n]*)+<属性値の正規表現>)”
ここでは、「¥n」は改行、「¥s」は半角空白、「¥t」はタブを意味するものとする。
At this time, the regular expression of the text range condition of the header field of the e-mail has the following form.
(1) When header field is one line Regular expression: “(^ | ¥ n) <Header field name>: [^ ¥ n] * <Regular expression of attribute value>”
(2) When header field extends over multiple lines Regular expression: “(^ | ¥ n) <Header field name>: [^ ¥ n] * (<Regular expression of attribute value> | (¥ n (¥ s | ¥ t) ) + [^ \ N] *) + <regular expression of attribute value>) "
Here, “¥ n” means a line feed, “¥ s” means a single-byte space, and “¥ t” means a tab.
例えば、電子メールの表題(Subject)に文字列「メール」を含む属性値を検索したい場合、正規表現生成装置100の入力は、次の情報を含んでいればよい。
(a)文書の形式=「電子メールのヘッダフィールド」
(b)検索対象の範囲(ヘッダフィールド名)=「Subject」
(c)範囲の検索条件(正規表現)=「メール」
これらの条件を指定することが可能であれば、その指定の方法は問わないが、例えば、テキスト範囲条件入力部109が、テキスト範囲条件として、(a)文書の形式と(b)検索対象の範囲を指定し、属性範囲条件入力部101が、属性範囲条件として、(c)範囲の検索条件を指定すればよい(このとき、属性範囲条件入力部101は、範囲の検索条件を指定することで、属性値がテキスト範囲条件データに示された範囲に含まれることも示したこととなる)。
For example, when searching for an attribute value that includes the character string “mail” in the title (Subject) of the electronic mail, the input of the regular
(A) Document format = “e-mail header field”
(B) Search target range (header field name) = “Subject”
(C) Range search condition (regular expression) = "mail"
As long as these conditions can be specified, the method of specifying them is not limited. For example, the text range
上記の入力を受けて、正規表現生成部104と正規表現結合部105とで、以下のように、上記の電子メールのヘッダフィールドのテキスト範囲条件の正規表現中の<ヘッダフィールド名>を「Subject」に、<属性値の正規表現>を「メール」に置き換えた正規表現を出力する。
“(^|¥n)Subject:[^¥n]*((メール)|(¥n(¥s|¥t)+[^¥n]*)+(メール))”
ここで、検索対象のヘッダフィールドが、複数行にわたることがないことがわかっていれば、単に以下の正規表現を出力するようにしてもよい。
“(^|¥n)Subject:[^¥n]*(メール)”
In response to the above input, the regular
“(^ | ¥ n) Subject: [^ ¥ n] * ((mail) | (¥ n (¥ s | ¥ t) + [^ ¥ n] *) + (mail))”
Here, if it is known that the header field to be searched does not extend over a plurality of lines, the following regular expression may be simply output.
“(^ | ¥ n) Subject: [^ ¥ n] * (mail)”
電子メールの送信日時を表すヘッダフィールド(Date)のような対象に、その下限値と上限値とを指定した検索を実行するための正規表現を生成する手順を示す。このときの正規表現生成装置100の入力は、以下の通りである。
(a)文書の形式=「電子メールのヘッダフィールド」
(b)検索対象の範囲(ヘッダフィールド名)=「Date」
(c)検索条件(下限値と上限値)=「2005/10/1〜2006/9/31」
例えば、テキスト範囲条件入力部109が、テキスト範囲条件として、(a)文書の形式と(b)検索対象の範囲を指定し、属性範囲条件入力部101が、属性範囲条件として、(c)範囲の検索条件を指定する。
A procedure for generating a regular expression for executing a search specifying a lower limit value and an upper limit value for a target such as a header field (Date) indicating the transmission date and time of an e-mail will be described. The input of the regular
(A) Document format = “e-mail header field”
(B) Search target range (header field name) = “Date”
(C) Search conditions (lower limit and upper limit) = “2005/10/1 to 2006/9/31”
For example, the text range
また、属性範囲条件入力部101が、属性範囲条件として、以下の条件も指定する。
(d)属性の種類=「日付」
(e)区切り文字と階層の順序=「日 月 年」(区切り文字が空白文字(厳密には、半角空白)で、右から順に上位とする)
(f)階層「月」の値域=「Jan〜Dec」
The attribute range
(D) Attribute type = “date”
(E) Delimiter and hierarchy order = “day, month, year” (separator is a space character (strictly, a single-byte space), and the higher order from the right)
(F) Value range of the hierarchy “month” = “Jan to Dec”
ここから、正規表現生成部104は、テキスト範囲条件の正規表現と、属性範囲条件の正規表現を以下のように生成することができる。
範囲:“(^|¥n)<ヘッダフィールド名>:[^¥n]*<属性値の正規表現>”
属性範囲(属性値の正規表現):“(([1−9]|[12][0−9]|3[0−1]) (Oct|Nov|Dec) 2005)|(([1−9]|[12][0−9]|3[0−1]) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep) 2006)”
最後に、正規表現結合部105が、これらを結合すると、所望の正規表現を得ることができる。
From here, the regular
Range: “(^ | ¥ n) <Header field name>: [^ ¥ n] * <Regular expression of attribute value>”
Attribute range (regular expression of attribute value): “(([1-9] | [12] [0-9] | 3 [0-1]) (Oct | Nov | Dec) 2005) | (([1- 9] | [12] [0-9] | 3 [0-1]) (Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep) 2006) "
Finally, when the regular
CSV形式のテキストの場合でも、正規表現の生成手順は電子メールの場合と同様である。CSV形式のテキストの各行のi番目とi+1番目のカンマに挟まれた範囲を対象に、正規表現によって検索する場合、範囲を特定するための正規表現は、以下の形式になる。
“(^|¥n)([^,]*,){i}[^,]*<属性値の正規表現>”
Even in the case of CSV text, the regular expression generation procedure is the same as in the case of electronic mail. When searching for a range sandwiched between the i-th and i + 1-th commas of each line of CSV format text by a regular expression, the regular expression for specifying the range is in the following format.
“(^ | ¥ n) ([^,] *,) {i} [^,] * <regular expression of attribute value>”
このときの、正規表現生成装置100の入力としては、次の情報が含まれていればよい。
(a)文書の形式=「CSV」
(b)検索対象の範囲(フィールドの番号)
(c)範囲の検索条件(正規表現)
例えば、テキスト範囲条件入力部109が、テキスト範囲条件として、(a)文書の形式と(b)検索対象の範囲を指定し、属性範囲条件入力部101が、属性範囲条件として、(c)範囲の検索条件を指定する。
At this time, the input to the regular
(A) Document format = “CSV”
(B) Search target range (field number)
(C) Range search condition (regular expression)
For example, the text range
正規表現には、各フィールドの値がダブルクォーテーション「”」で囲まれているものもある。各フィールドの値がダブルクォーテーションで囲まれているとき、値にカンマが含まれる場合や、値にダブルクォーテーションが2個連続して含まれる場合もある。このときのテキスト範囲の正規表現は以下の形式となる(左端と右端のダブルクォーテーションはこれまでに記述したものと同様、正規表現を強調表示するものであり、正規表現の一部ではない)。
“(^|¥n)(“([^”]|”“)*”,){i}”([^”]|”“)*<属性値の正規表現>”
In some regular expressions, the value of each field is enclosed in double quotation marks """. When the value of each field is enclosed in double quotations, the value may include a comma or the value may include two consecutive double quotations. The regular expression of the text range at this time is in the following format (double quotations on the left and right edges highlight the regular expression as described above and are not part of the regular expression).
"(^ | \ N) (" ([^ "] |"")*",) {i} "([^"] | "") * <regular expression of attribute value>"
TSV形式の場合は、上記のテキスト範囲の正規表現の区切り文字であるカンマ「,」を、以下の通りタブ(「¥t」で表す)に置き換えるだけでよい。
“(^|¥n)(“([^”]|”“)*”¥t){i}”([^”]|”“)*<属性値の正規表現>”
In the case of the TSV format, it is only necessary to replace the comma “,” which is a delimiter for the regular expression in the above text range with a tab (represented by “¥ t”) as follows.
"(^ | \ N) (" ([^ "] |"")*" \ t) {i} "([^"] | "") * <regular expression of attribute value>"
スペース区切り形式のテキストの場合は、上記のテキスト範囲の正規表現の区切り文字であるカンマ「,」やタブを、以下の通り半角空白(「¥s」で表す)に置き換えるだけでよい。
“(^|¥n)(“([^”]|”“)*”¥s){i}”([^”]|”“)*<属性値の正規表現>”
In the case of the text in the space delimited format, the comma “,” or tab that is the delimiter for the regular expression in the above text range need only be replaced with a single-byte space (represented by “¥ s”) as follows.
"(^ | \ N) (" ([^ "] |""" * "\ s) {i}" ([^ "] |"") * <regular expression of attribute value>"
また、区切り文字の連続を1個の区切り文字と見なす場合は、単体の区切り文字を“<区切り文字>+”の形式に変更するだけでよい。 In addition, when a series of delimiters is regarded as a single delimiter, it is only necessary to change the single delimiter to the “<delimiter> +” format.
実施の形態1や3において、属性範囲条件の正規表現の前に除外文字指定“[^v1−vq]”という表現を追加することにより、属性範囲条件を厳密に照合する方法を示した。このような属性範囲条件の正規表現と、CSV形式やTSV形式などのフィールドが区切り文字で区切られたテキストを検索するテキスト範囲条件の正規表現を結合する場合には、直前の除外文字指定と合わせて、除外文字指定に区切り文字も含めて記述する。即ち、以下のように正規表現を構成する。
正規表現:“(^|¥n)([^<区切り文字>]*<区切り文字>){i}[^v1−vq<区切り文字>]*<属性値の正規表現>”
これにより、“[^v1−vq]”に区切り文字自体が照合されてしまうのを防ぐことができる。
In the first and third embodiments, the method of strictly matching the attribute range condition by adding the expression “[^ v 1 −v q ]” to be excluded before the regular expression of the attribute range condition is shown. . When combining a regular expression of such an attribute range condition and a regular expression of a text range condition for searching for text in which fields such as CSV format or TSV format are separated by a delimiter, it is combined with the preceding exclusion character specification. And include the delimiter in the exclusion character specification. That is, a regular expression is constructed as follows.
Regular expression: “(^ | ¥ n) ([^ <delimiter>] * <delimiter>) {i} [^ v 1 −v q <delimiter>] * <regular expression of attribute value>”
Thereby, it is possible to prevent the delimiter character from being collated with “[^ v 1 −v q ]”.
以上のように、本実施の形態に係る正規表現生成装置100によれば、既定の構文・書式に従って記述されたテキストの中の、特定の範囲を指定するテキスト範囲条件と、正規表現又は属性範囲条件から、その範囲に含まれる文字列を照合するための正規表現を自動的に生成することができる。これにより、従来は正確に記述することが困難であった複雑な属性範囲条件を照合する正規表現を、特別な知識も試行錯誤も必要なく、容易に短時間で得ることができる。
As described above, according to the regular
以上、本発明の実施の形態について説明したが、これらのうち、2つ以上の実施の形態を組み合わせて実施しても構わない。あるいは、これらのうち、1つの実施の形態を部分的に実施しても構わない。あるいは、これらのうち、2つ以上の実施の形態を部分的に組み合わせて実施しても構わない。 As mentioned above, although embodiment of this invention was described, you may implement combining 2 or more embodiment among these. Alternatively, one of these embodiments may be partially implemented. Or you may implement combining two or more embodiment among these partially.
100 正規表現生成装置、101 属性範囲条件入力部、102 演算部、103 属性値記憶部、104 正規表現生成部、105 正規表現結合部、106 出力部、107 条件記憶部、108 識別子入力部、109 テキスト範囲条件入力部、151 記憶装置、152 処理装置、153 入力装置、154 出力装置、901 表示装置、902 キーボード、903 マウス、904 FDD、905 CDD、906 プリンタ装置、910 システムユニット、911 CPU、912 バス、913 ROM、914 RAM、915 通信ボード、920 磁気ディスク装置、921 オペレーティングシステム、922 ウィンドウシステム、923 プログラム群、924 ファイル群、940 インターネット、941 ゲートウェイ、942 LAN。 100 regular expression generator, 101 attribute range condition input unit, 102 arithmetic unit, 103 attribute value storage unit, 104 regular expression generation unit, 105 regular expression combination unit, 106 output unit, 107 condition storage unit, 108 identifier input unit, 109 Text range condition input unit, 151 storage device, 152 processing device, 153 input device, 154 output device, 901 display device, 902 keyboard, 903 mouse, 904 FDD, 905 CDD, 906 printer device, 910 system unit, 911 CPU, 912 Bus, 913 ROM, 914 RAM, 915 communication board, 920 magnetic disk drive, 921 operating system, 922 window system, 923 programs, 924 files, 940 Internet, 941 gateway Lee, 942 LAN.
Claims (12)
前記属性範囲条件入力部により入力された属性範囲条件データが示す書式に基づいて、前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値以上の属性値であって、最下位桁から少なくとも1桁が当該桁の最大値である第1の値と、前記属性範囲条件入力部により入力された属性範囲条件データが示す上限値以下の属性値であって、最下位桁から少なくとも1桁が当該桁の最小値である第2の値とを、処理装置で演算する演算部と、
前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値と上限値と、前記演算部により演算された第1の値と第2の値とを、記憶装置に記憶する属性値記憶部と、
前記属性値記憶部により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データと、前記属性値記憶部により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データとを、処理装置で生成するとともに、前記属性値記憶部により記憶された第1の値と第2の値との間に属性値が存在する場合には当該属性値を正規表現で表す中位領域データを処理装置で生成する正規表現生成部と、
前記正規表現生成部により生成された下位領域データと上位領域データと中位領域データとを処理装置で結合して、前記属性値記憶部により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データを生成する正規表現結合部とを備えることを特徴とする正規表現生成装置。 An attribute range condition input unit for inputting attribute range condition data indicating a lower limit value, an upper limit value and a format of the attribute value from an input device;
Based on the format indicated by the attribute range condition data input by the attribute range condition input unit, the attribute value is equal to or greater than the lower limit value indicated by the attribute range condition data input by the attribute range condition input unit, and the least significant digit A first value in which at least one digit is the maximum value of the digit and an attribute value equal to or lower than the upper limit value indicated by the attribute range condition data input by the attribute range condition input unit, and at least 1 from the lowest digit A computing unit that computes the second value, the digit of which is the minimum value of the digit, by the processing device;
Attribute value storage that stores the lower limit value and the upper limit value indicated by the attribute range condition data input by the attribute range condition input unit, and the first value and the second value calculated by the calculation unit in a storage device And
Lower region data representing the attribute value from the lower limit value to the first value stored by the attribute value storage unit in a regular expression, and the attribute value from the second value to the upper limit value stored by the attribute value storage unit If the attribute value exists between the first value and the second value stored in the attribute value storage unit, the upper region data representing the regular expression in the regular expression is generated by the processing device. A regular expression generating unit that generates intermediate region data representing a value in a regular expression by a processing device;
The lower region data, the upper region data, and the middle region data generated by the regular expression generation unit are combined by a processing device, and the attribute values from the lower limit value to the upper limit value stored in the attribute value storage unit are normalized. A regular expression generation apparatus comprising: a regular expression combining unit that generates regular expression data represented by an expression.
前記演算部は、属性値全体について、各階層を1桁として、第1の値と第2の値とを演算し、
前記正規表現生成部は、属性値全体について、各階層を1桁として、下位領域データと上位領域データとを生成した後に、下位領域データと上位領域データとを各階層を正規表現で表すものに変換するとともに、第1の値と第2の値との間に属性値が存在する場合には中位領域データを生成し、さらに、各階層を正規表現で表すものに変換することを特徴とする請求項1に記載の正規表現生成装置。 The attribute range condition input unit is an attribute value in which the attribute value has a hierarchical structure using a delimiter as a format of the attribute value, and each of the portions where the entire attribute value is delimited by the delimiter is one layer of the hierarchical structure Attribute range condition data indicating that
The calculation unit calculates a first value and a second value for each attribute value as a single digit for the entire attribute value,
The regular expression generation unit generates the lower area data and the upper area data for each attribute value as a single digit with respect to the entire attribute value, and then represents the lower area data and the upper area data in a regular expression. Converting, generating an intermediate region data when an attribute value exists between the first value and the second value, and further converting each layer into one represented by a regular expression The regular expression generation device according to claim 1.
所定の構文規則に従って記述されたテキストの特定の領域を示すテキスト範囲条件データを入力装置から入力するテキスト範囲条件入力部を備え、
前記属性範囲条件入力部は、属性値の書式として、属性値が前記テキスト範囲条件入力部により入力されたテキスト範囲条件データが示す領域に含まれることを示す属性範囲条件データを入力し、
前記正規表現生成部は、さらに、前記テキスト範囲条件入力部により入力されたテキスト範囲条件データが示す領域を正規表現で表すテキスト領域データを処理装置で生成し、
前記正規表現結合部は、前記属性範囲条件入力部により入力された属性範囲条件データが示す書式に基づいて、前記正規表現生成部により生成された下位領域データと上位領域データと中位領域データとテキスト領域データとを結合して、属性値を含む前記テキストの特定の領域を正規表現で表す正規表現データを生成することを特徴とする請求項1に記載の正規表現生成装置。 The regular expression generation device further includes:
A text range condition input unit for inputting text range condition data indicating a specific area of text described according to a predetermined syntax rule from an input device;
The attribute range condition input unit inputs attribute range condition data indicating that the attribute value is included in an area indicated by the text range condition data input by the text range condition input unit as a format of the attribute value,
The regular expression generation unit further generates text region data representing the region indicated by the text range condition data input by the text range condition input unit with a regular expression by a processing device,
The regular expression combining unit, based on the format indicated by the attribute range condition data input by the attribute range condition input unit, lower region data, upper region data, and middle region data generated by the regular expression generation unit, The regular expression generation device according to claim 1, wherein the regular expression data is generated by combining the text area data and expressing the specific area of the text including the attribute value by a regular expression.
複数の属性範囲条件データと複数のテキスト範囲条件データとを予め記憶装置に記憶しておくとともに、各属性範囲条件データと各テキスト範囲条件データとの組み合わせを一意の識別子と対応付けて予め記憶装置に記憶しておく条件記憶部と、
任意の識別子を入力装置から入力する識別子入力部とを備え、
前記属性範囲条件入力部は、前記識別子入力部により入力された識別子に対応付けて前記条件記憶部により記憶された組み合わせの属性範囲条件データを入力し、
前記テキスト範囲条件入力部は、前記識別子入力部により入力された識別子に対応付けて前記条件記憶部により記憶された組み合わせのテキスト範囲条件データを入力することを特徴とする請求項7に記載の正規表現生成装置。 The regular expression generation device further includes:
A plurality of attribute range condition data and a plurality of text range condition data are stored in advance in a storage device, and a combination of each attribute range condition data and each text range condition data is associated with a unique identifier in advance. A condition storage unit for storing
An identifier input unit for inputting an arbitrary identifier from an input device;
The attribute range condition input unit inputs attribute range condition data of a combination stored by the condition storage unit in association with the identifier input by the identifier input unit,
The regular text range condition input unit according to claim 7, wherein the text range condition input unit inputs the text range condition data of the combination stored in the condition storage unit in association with the identifier input by the identifier input unit. Expression generator.
前記正規表現生成装置の演算部が、前記属性範囲条件入力部により入力された属性範囲条件データが示す書式に基づいて、前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値以上の属性値であって、最下位桁から少なくとも1桁が当該桁の最大値である第1の値と、前記属性範囲条件入力部により入力された属性範囲条件データが示す上限値以下の属性値であって、最下位桁から少なくとも1桁が当該桁の最小値である第2の値とを、処理装置で演算し、
前記正規表現生成装置の属性値記憶部が、前記属性範囲条件入力部により入力された属性範囲条件データが示す下限値と上限値と、前記演算部により演算された第1の値と第2の値とを、記憶装置に記憶し、
前記正規表現生成装置の正規表現生成部が、前記属性値記憶部により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データと、前記属性値記憶部により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データとを、処理装置で生成し、
前記正規表現生成装置の正規表現生成部が、前記属性値記憶部により記憶された第1の値と第2の値との間に属性値が存在する場合には当該属性値を正規表現で表す中位領域データを処理装置で生成し、
前記正規表現生成装置の正規表現結合部が、前記正規表現生成部により生成された下位領域データと上位領域データと中位領域データとを処理装置で結合して、前記属性値記憶部により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データを生成することを特徴とする正規表現生成方法。 The attribute range condition input unit of the regular expression generation device inputs attribute range condition data indicating the lower limit value, upper limit value and format of the attribute value from the input device,
Based on the format indicated by the attribute range condition data input by the attribute range condition input unit, the arithmetic unit of the regular expression generation apparatus is equal to or greater than the lower limit value indicated by the attribute range condition data input by the attribute range condition input unit. A first value in which at least one digit from the least significant digit is the maximum value of the digit, and an attribute value equal to or lower than the upper limit value indicated by the attribute range condition data input by the attribute range condition input unit And a processing device calculates a second value in which at least one digit from the least significant digit is the minimum value of the digit,
The attribute value storage unit of the regular expression generation device includes a lower limit value and an upper limit value indicated by the attribute range condition data input by the attribute range condition input unit, a first value calculated by the calculation unit, and a second value Store the value in a storage device,
The regular expression generation unit of the regular expression generation device stores lower region data representing the attribute value from the lower limit value to the first value stored in the attribute value storage unit in a regular expression, and is stored in the attribute value storage unit. High-order area data representing the attribute value from the second value to the upper limit value with a regular expression is generated by the processing device,
When a regular expression generating unit of the regular expression generating device has an attribute value between the first value and the second value stored by the attribute value storage unit, the regular value generating unit represents the attribute value by a regular expression. The middle region data is generated by the processing device,
The regular expression combining unit of the regular expression generating device combines the lower region data, the upper region data, and the middle region data generated by the regular expression generating unit with a processing device, and is stored in the attribute value storage unit. A regular expression generation method characterized by generating regular expression data representing an attribute value from a lower limit value to an upper limit value by a regular expression.
前記属性範囲条件入力処理により入力された属性範囲条件データが示す書式に基づいて、前記属性範囲条件入力処理により入力された属性範囲条件データが示す下限値以上の属性値であって、最下位桁から少なくとも1桁が当該桁の最大値である第1の値と、前記属性範囲条件入力処理により入力された属性範囲条件データが示す上限値以下の属性値であって、最下位桁から少なくとも1桁が当該桁の最小値である第2の値とを、処理装置で演算する演算処理と、
前記属性範囲条件入力処理により入力された属性範囲条件データが示す下限値と上限値と、前記演算処理により演算された第1の値と第2の値とを、記憶装置に記憶する属性値記憶処理と、
前記属性値記憶処理により記憶された下限値から第1の値までの属性値を正規表現で表す下位領域データと、前記属性値記憶処理により記憶された第2の値から上限値までの属性値を正規表現で表す上位領域データとを、処理装置で生成するとともに、前記属性値記憶処理により記憶された第1の値と第2の値との間に属性値が存在する場合には当該属性値を正規表現で表す中位領域データを処理装置で生成する正規表現生成処理と、
前記正規表現生成処理により生成された下位領域データと上位領域データと中位領域データとを処理装置で結合して、前記属性値記憶処理により記憶された下限値から上限値までの属性値を正規表現で表す正規表現データを生成する正規表現結合処理とをコンピュータに実行させることを特徴とする正規表現生成プログラム。 Attribute range condition input processing for inputting attribute range condition data indicating the lower limit value, upper limit value and format of the attribute value from the input device;
Based on the format indicated by the attribute range condition data input by the attribute range condition input process, the attribute value is equal to or greater than the lower limit value indicated by the attribute range condition data input by the attribute range condition input process, and the least significant digit A first value in which at least one digit is the maximum value of the digit, and an attribute value equal to or lower than the upper limit value indicated by the attribute range condition data input by the attribute range condition input process, and at least 1 from the least significant digit An arithmetic process in which a processing unit calculates a second value whose digit is the minimum value of the digit;
Attribute value storage that stores the lower limit value and the upper limit value indicated by the attribute range condition data input by the attribute range condition input process, and the first value and the second value calculated by the calculation process in a storage device Processing,
Lower region data representing the attribute value from the lower limit value to the first value stored by the attribute value storage processing by a regular expression, and the attribute value from the second value to the upper limit value stored by the attribute value storage processing When the attribute value exists between the first value and the second value stored by the attribute value storage process, the upper region data representing the regular expression in the regular expression is generated by the processing device. A regular expression generation process for generating intermediate region data representing a value in a regular expression by a processing device;
The lower region data, the upper region data, and the middle region data generated by the regular expression generation process are combined by a processing device, and the attribute values from the lower limit value to the upper limit value stored by the attribute value storage process are normalized. A regular expression generation program that causes a computer to execute regular expression combining processing for generating regular expression data represented by an expression.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006329679A JP4897454B2 (en) | 2006-12-06 | 2006-12-06 | Regular expression generation device, regular expression generation method, and regular expression generation program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006329679A JP4897454B2 (en) | 2006-12-06 | 2006-12-06 | Regular expression generation device, regular expression generation method, and regular expression generation program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2008146162A true JP2008146162A (en) | 2008-06-26 |
JP4897454B2 JP4897454B2 (en) | 2012-03-14 |
Family
ID=39606310
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2006329679A Active JP4897454B2 (en) | 2006-12-06 | 2006-12-06 | Regular expression generation device, regular expression generation method, and regular expression generation program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4897454B2 (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2011034274A (en) * | 2009-07-31 | 2011-02-17 | Hitachi Solutions Ltd | Automatic test execution system |
JP2011198333A (en) * | 2010-03-24 | 2011-10-06 | Mitsubishi Denki Information Technology Corp | Data processor and program |
JP2012084054A (en) * | 2010-10-14 | 2012-04-26 | Kddi Corp | Portable terminal and program |
JP7393357B2 (en) | 2018-06-13 | 2023-12-06 | オラクル・インターナショナル・コーポレイション | Regular expression generation based on positive and negative pattern matching examples |
US11941018B2 (en) | 2018-06-13 | 2024-03-26 | Oracle International Corporation | Regular expression generation for negative example using context |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0628196A (en) * | 1992-01-21 | 1994-02-04 | Hewlett Packard Co <Hp> | Apparatus, system and method for discrimination of regular expression |
JPH11167566A (en) * | 1997-12-04 | 1999-06-22 | Nippon Telegr & Teleph Corp <Ntt> | Output device adaptive type batch text conversion method and device and recording medium |
WO2001033786A1 (en) * | 1999-11-02 | 2001-05-10 | Ntt Docomo, Inc. | Client server system |
-
2006
- 2006-12-06 JP JP2006329679A patent/JP4897454B2/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0628196A (en) * | 1992-01-21 | 1994-02-04 | Hewlett Packard Co <Hp> | Apparatus, system and method for discrimination of regular expression |
JPH11167566A (en) * | 1997-12-04 | 1999-06-22 | Nippon Telegr & Teleph Corp <Ntt> | Output device adaptive type batch text conversion method and device and recording medium |
WO2001033786A1 (en) * | 1999-11-02 | 2001-05-10 | Ntt Docomo, Inc. | Client server system |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2011034274A (en) * | 2009-07-31 | 2011-02-17 | Hitachi Solutions Ltd | Automatic test execution system |
JP2011198333A (en) * | 2010-03-24 | 2011-10-06 | Mitsubishi Denki Information Technology Corp | Data processor and program |
JP2012084054A (en) * | 2010-10-14 | 2012-04-26 | Kddi Corp | Portable terminal and program |
JP7393357B2 (en) | 2018-06-13 | 2023-12-06 | オラクル・インターナショナル・コーポレイション | Regular expression generation based on positive and negative pattern matching examples |
US11941018B2 (en) | 2018-06-13 | 2024-03-26 | Oracle International Corporation | Regular expression generation for negative example using context |
JP7493462B2 (en) | 2018-06-13 | 2024-05-31 | オラクル・インターナショナル・コーポレイション | Generating Regular Expressions Using the Longest Common Subsequence Algorithm on Regular Expression Code |
Also Published As
Publication number | Publication date |
---|---|
JP4897454B2 (en) | 2012-03-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10795922B2 (en) | Authorship enhanced corpus ingestion for natural language processing | |
EP1522933B1 (en) | Computer aided query to task mapping | |
JP3566111B2 (en) | Symbol dictionary creation method and symbol dictionary search method | |
US8073849B2 (en) | Method and system for constructing data tag based on a concept relation network | |
CN106383836B (en) | Attributing actionable attributes to data describing an identity of an individual | |
US20120166438A1 (en) | System and method for recommending queries related to trending topics based on a received query | |
US20080319987A1 (en) | System, method and program for creating index for database | |
US8266150B1 (en) | Scalable document signature search engine | |
US20180267953A1 (en) | Context-based text auto completion | |
US20150026178A1 (en) | Subject-matter analysis of tabular data | |
KR20060045535A (en) | Efficient capitalization through user modeling | |
JP4897454B2 (en) | Regular expression generation device, regular expression generation method, and regular expression generation program | |
Xu et al. | A new feature selection method based on support vector machines for text categorisation | |
US7676487B2 (en) | Method and system for formatting and indexing data | |
Mehta et al. | WEClustering: word embeddings based text clustering technique for large datasets | |
Claesson et al. | Counting pop-stacked permutations in polynomial time | |
US8266228B2 (en) | Tagging communication files based on historical association of tags | |
Prathima et al. | Automatic extractive text summarization using K-means clustering | |
US11308084B2 (en) | Optimized search service | |
US20210192125A1 (en) | Methods and systems for facilitating summarization of a document | |
US8918383B2 (en) | Vector space lightweight directory access protocol data search | |
Sohrabi et al. | Finding similar documents using frequent pattern mining methods | |
Martin | Minimal auxiliary Markov chains through sequential elimination of states | |
Amazal et al. | A text classification approach using parallel naive Bayes in big data context | |
JP4937709B2 (en) | Structured document generation method, apparatus and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20091001 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20111202 |
|
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: 20111220 |
|
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: 20111222 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 4897454 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20150106 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 |