JPH04279973A - Character string comparison system - Google Patents

Character string comparison system

Info

Publication number
JPH04279973A
JPH04279973A JP3011449A JP1144991A JPH04279973A JP H04279973 A JPH04279973 A JP H04279973A JP 3011449 A JP3011449 A JP 3011449A JP 1144991 A JP1144991 A JP 1144991A JP H04279973 A JPH04279973 A JP H04279973A
Authority
JP
Japan
Prior art keywords
character
comparison
character strings
match
character string
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP3011449A
Other languages
Japanese (ja)
Inventor
Susumu Tanaka
進 田中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oki Electric Industry Co Ltd
Original Assignee
Oki Electric Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oki Electric Industry Co Ltd filed Critical Oki Electric Industry Co Ltd
Priority to JP3011449A priority Critical patent/JPH04279973A/en
Publication of JPH04279973A publication Critical patent/JPH04279973A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

PURPOSE:To perform various processings based on discrimination calculating the degree of resemblance to discriminate resembling character strings by numbers and discriminating it even in the case of disaccord that both character strings resemble very much. CONSTITUTION:This comparison system consists of a retrieving means 1, a comparing means 2, and a resemblance degree calculating means 3. In this case, the retrieving means 1 retrieves each character from both of character strings A and B in accordance with a prescribed algorithm. The comparing means 2 compares both characters retrieved by the retrieving means 1 and detects coincidence or disaccord between them as the result of this comparison and stores the detection result. The resemblance degree calculating means 3 calculates the degree of resemblance between both character strings in accordance with the comparison result of the comparing means 2 and outputs it. Thus, the problem that the quantity of discrimination information obtained by comparison between two character strings A and B is small is eliminated to evaluate the condition of difference between two character strings A and B by numbers in the case of character strings A and B different from each other.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、計算機におけるデータ
中に表われる文字列の比較を行なう方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method for comparing character strings appearing in data in a computer.

【0002】0002

【従来の技術】従来、この種の方式は、2つの文字列が
完全に一致するか否かの判定に限られていた。
2. Description of the Related Art Conventionally, this type of method has been limited to determining whether two character strings completely match.

【0003】図2は、従来の文字列比較方式の説明図で
ある。図示の方式では、文字列A及びBの比較を比較手
段21によって行なう。文字列A及びBは、レジスタ等
の記憶装置に格納された各1バイトの文字により構成さ
れる文字の列である。比較手段21は、文字列A及びB
を、例えば、1文字ずつ比較するようにした論理回路に
より構成される。この比較手段21は、文字列A及びB
を構成する対応するすべての文字が一致する場合には、
一致の旨を出力し、文字列A及びBを構成する文字のう
ち、1文字でも一致しない場合には、不一致の旨を出力
する。
FIG. 2 is an explanatory diagram of a conventional character string comparison method. In the illustrated system, character strings A and B are compared by comparison means 21. Character strings A and B are character strings each composed of 1-byte characters stored in a storage device such as a register. The comparison means 21 compares character strings A and B.
, for example, by a logic circuit that compares each character one by one. This comparison means 21 compares character strings A and B.
If all corresponding characters that make up match, then
A message to the effect of a match is output, and if even one character among the characters forming the character strings A and B does not match, a message to the effect of a mismatch is output.

【0004】0004

【発明が解決しようとする課題】しかしながら、上述し
た従来の技術には、次のような問題があった。即ち、文
字列の一致のみが判定され、2つの文字列が全く異なる
文字から構成されているとか非常に類似しており一部の
みに相異があるといった情報は得られなかった。従って
、文字列の比較結果は、ごく限られた処理にしか使用す
ることができないという問題があった。
[Problems to be Solved by the Invention] However, the above-mentioned conventional technology has the following problems. In other words, only a match between the character strings was determined, and no information such as whether two character strings were composed of completely different characters or were very similar and differed only in part could not be obtained. Therefore, there has been a problem in that the comparison results of character strings can only be used for very limited processing.

【0005】本発明は、以上の点に着目してなされたも
ので、2つの文字列の比較において得られる判定情報が
少ないという問題点を除去し、2つの文字列が異なる場
合にどの程度異なるかという状況を数字で評価する方式
を提供することを目的とするものである。
The present invention has been made with attention to the above points, and eliminates the problem that there is little judgment information obtained when comparing two character strings, and determines how much the two character strings differ when they differ. The purpose of this study is to provide a method for numerically evaluating the situation.

【0006】[0006]

【課題を解決するための手段】本発明の文字列比較方式
は、双方の文字列から各文字を探索する探索手段と、当
該探索手段により探索された両文字を比較し、一致か不
一致かを検出して記憶する比較手段と、当該比較手段の
比較結果に従って双方の文字列の類似度を計算して出力
する類似度計算手段とから成ることを特徴とするもので
ある。
[Means for Solving the Problems] The character string comparison method of the present invention includes a search means for searching each character from both character strings, and a comparison between both characters searched by the search means to determine whether they match or do not match. This method is characterized by comprising a comparison means for detecting and storing the information, and a similarity calculation means for calculating and outputting the similarity between both character strings according to the comparison result of the comparison means.

【0007】[0007]

【実施例】以下、本発明の実施例を図面を参照して詳細
に説明する。図1は、本発明の文字列比較方式の実施例
のブロック図である。図示の方式は、探索手段1と、比
較手段2と、類似度計算手段3とから成る。
Embodiments Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. FIG. 1 is a block diagram of an embodiment of the string comparison method of the present invention. The illustrated system includes a search means 1, a comparison means 2, and a similarity calculation means 3.

【0008】探索手段1は、所定のアルゴリズムに従っ
て、双方の文字列A及びBから各1文字ずつを探索する
。このアルゴリズムの詳細については、後述する。比較
手段2は、探索手段1により探索された両文字を比較す
る。そして、この比較の結果、両文字が一致か不一致か
を検出して記憶する。類似度計算手段3は、比較手段2
の比較結果に従って双方の文字列の類似度を計算して出
力する。
Search means 1 searches for one character each from both character strings A and B according to a predetermined algorithm. Details of this algorithm will be described later. Comparison means 2 compares both characters searched by search means 1. As a result of this comparison, whether the two characters match or do not match is detected and stored. The similarity calculation means 3 is the comparison means 2.
The similarity between both strings is calculated and output according to the comparison result.

【0009】図3及び図4は、文字列探索のアルゴリズ
ムの説明図である。比較しようとする2つの文字列の先
頭の文字からそれぞれ“1”、“2”、“3”、…と文
字番号を振る。そして、比較手段2による比較の結果、
もし、文字番号“1”の文字同士が一致した場合は探索
及び比較を終了する。
FIGS. 3 and 4 are explanatory diagrams of the character string search algorithm. Assign character numbers "1", "2", "3", etc. from the first character of the two character strings to be compared. As a result of the comparison by comparison means 2,
If the characters with the character number "1" match, the search and comparison are terminated.

【0010】不一致の場合は、一方の文字列の文字番号
“1”の文字と、他方の文字列の文字番号“2”の文字
とを探索して比較する。この比較の結果、もし、これら
の文字同士が一致した場合は探索及び比較を終了する。 不一致の場合は、一方の文字列の文字番号“2”の文字
と、他方の文字列の文字番号“1”の文字とを探索して
比較する。この比較の結果、もし、これらの文字同士が
一致した場合は探索及び比較を終了する。不一致の場合
は、一方の文字列の文字番号“2”の文字と、他方の文
字列の文字番号“2”の文字とを探索して比較する。こ
の比較の結果、もし、これらの文字同士が一致した場合
は、探索を終了する。
If they do not match, the character with character number "1" in one character string is searched for and compared with the character with character number "2" in the other character string. As a result of this comparison, if these characters match, the search and comparison ends. If they do not match, the character with character number "2" in one character string is searched for and compared with the character with character number "1" in the other character string. As a result of this comparison, if these characters match, the search and comparison ends. If they do not match, the character with character number "2" in one character string is searched for and compared with the character with character number "2" in the other character string. As a result of this comparison, if these characters match, the search ends.

【0011】不一致の場合は、一方の文字列の文字番号
“1”の文字と、他方の文字列の文字番号“3”の文字
とを探索して比較する。この比較の結果、もし、これら
の文字同士が一致した場合は探索及び比較を終了する。 不一致の場合は、同様にして探索及び比較を続ける。こ
の探索の順序を図中の番号で示す。また、これを表で示
せば、図4のようになる。一方、文字の一致により探索
が終了した場合は、次の文字から文字番号を振り直して
図3及び図4のアルゴリズムに従った探索を繰り返す。
If they do not match, the character with character number "1" in one character string is searched for and compared with the character with character number "3" in the other character string. As a result of this comparison, if these characters match, the search and comparison ends. If there is a mismatch, the search and comparison continue in the same way. The order of this search is indicated by the numbers in the figure. Moreover, if this is shown in a table, it will be as shown in FIG. On the other hand, if the search ends due to a match of characters, the character numbers are reassigned from the next character and the search is repeated according to the algorithms of FIGS. 3 and 4.

【0012】図1では、一致した文字同士を線で結んで
示している。即ち、第1回目の探索及び比較により、文
字列Aの第1番目の文字“a”と、文字列Bの第1番目
の文字“a”との一致が検出されるので、これらを線で
結んで示す。
In FIG. 1, matched characters are shown connected by lines. In other words, the first search and comparison detects a match between the first character "a" of character string A and the first character "a" of character string B, so these can be drawn as a line. Tie and show.

【0013】次に、第2回目の探索及び比較では、文字
列Aの第2番目の文字“1”と、文字列Bの第2番目の
文字“2”とから、図3に従って文字番号を振り直して
比較及び探索を行なう。この結果、図1において、文字
列Aの第2番目の文字“1”と、文字列Bの第3番目の
文字“1”との一致が検出されるので、これらを線で結
んで示す。
Next, in the second search and comparison, character numbers are determined from the second character "1" of character string A and the second character "2" of character string B according to FIG. Redraw and compare and explore. As a result, in FIG. 1, a match is detected between the second character "1" of character string A and the third character "1" of character string B, and these are shown connected by a line.

【0014】次に、第3回目の探索及び比較では、文字
列Aの第3番目の文字“2”と、文字列Bの第4番目の
文字“3”とから、図3に従って文字番号を振り直して
比較及び探索を行なう。この結果、図1において、文字
列Aの第4番目の文字“3”と、文字列Bの第4番目の
文字“3”との一致が検出されるので、これらを線で結
んで示す。この場合、同図中点線で示すような文字列A
の第3番目の文字“2”と、文字列Bの第2番目の文字
“2”とは、一致したものとはされない。このような場
合まで一致したものとすると、同図において、文字列A
の第1〜3番目の文字と、文字列Bの第1〜3番目の文
字とがすべて一致した場合と区別できなくなってしまう
からである。
Next, in the third search and comparison, character numbers are determined from the third character "2" of character string A and the fourth character "3" of character string B according to FIG. Redraw and compare and explore. As a result, in FIG. 1, a match is detected between the fourth character "3" of character string A and the fourth character "3" of character string B, and these are shown connected by a line. In this case, the character string A as shown by the dotted line in the figure
The third character "2" in the character string B and the second character "2" in the character string B are not considered to be a match. Assuming that there is a match in such cases, in the same figure, the character string A
This is because the first to third characters of the character string B cannot be distinguished from the case where the first to third characters of the character string B all match.

【0015】次に、第4回目の探索及び比較では、文字
列Aの第5番目の文字“4”と、文字列Bの第5番目の
文字“5”とから、図3に従って文字番号を振り直して
比較及び探索を行なう。この結果、図1において、文字
列Aの第6番目の文字“5”と、文字列Bの第5番目の
文字“5”との一致が検出されるので、これらを線で結
んで示す。以後、同様に第5回目以降の探索及び比較を
行なっていき、最終的に図示のような比較結果が得られ
る。図1の例では、文字列Aの12文字と、文字列Bの
13文字のうち、7文字が一致していると見なされる。
Next, in the fourth search and comparison, character numbers are determined from the fifth character "4" of character string A and the fifth character "5" of character string B according to FIG. Redraw and compare and explore. As a result, in FIG. 1, a match is detected between the sixth character "5" of character string A and the fifth character "5" of character string B, and these are shown connected by a line. Thereafter, searches and comparisons are performed in the same manner from the fifth time onwards, and the comparison results as shown in the figure are finally obtained. In the example of FIG. 1, 7 characters out of 12 characters of character string A and 13 characters of character string B are considered to match.

【0016】次に、この比較結果に基づいた類似度の計
算例を説明する。代表的な例は、一致した文字数の長い
ほうの文字列の文字数に対する割合で表現したものであ
る。この計算例に従うと、図1の例の場合の類似度は、
(7/13)×100 =54%となる。他の例として
は、一致した文字数が同数でも、集中しているか分散し
ているかにより類似度が微妙に異なると解釈して、この
度合いを類似度に含めるものがある。この計算例に従う
と、図1の例の場合の類似度は、(7/15)×100
 =60%となる。いずれの計算例を採用するにしても
、類似度は、一致(類似度 100%)か不一致(類似
度0%)の概念を拡張したものとなる。この類似度を使
用し、類似か非類似かを定める場合に、ボーダーライン
を自由に定めて判定することができる。
Next, an example of calculating the degree of similarity based on this comparison result will be explained. A typical example is expressed as a ratio of the number of matched characters to the number of characters in the longer string. According to this calculation example, the similarity in the case of the example in Figure 1 is
(7/13) x 100 = 54%. Another example is one that interprets that even if the number of matched characters is the same, the degree of similarity differs slightly depending on whether the characters are concentrated or dispersed, and this degree is included in the degree of similarity. According to this calculation example, the similarity in the case of the example in Figure 1 is (7/15) x 100
=60%. Regardless of which calculation example is adopted, the degree of similarity is an extension of the concept of match (similarity 100%) or mismatch (similarity 0%). When determining similarity or dissimilarity using this degree of similarity, a borderline can be freely defined for determination.

【0017】図5は、本発明の方式と従来の方式の相違
の説明図である。文字列A及びBがそれぞれ図示のよう
な5文字から成る場合、従来の方式では、5文字が完全
に一致するときのみ“1”が出力された。そして、それ
以外のときは、0が出力された。一方、本発明の方式で
は、5文字のうち1文字のみが不一致で他の4文字が一
致するときは、0.8 が出力される。また、5文字の
うち2文字が一致し、他の3文字が不一致のときは、0
.4 が出力される。そして、5文字のすべてが不一致
のときには、0が出力される。
FIG. 5 is an explanatory diagram of the difference between the method of the present invention and the conventional method. When character strings A and B each consist of five characters as shown, in the conventional system, "1" is output only when the five characters completely match. In other cases, 0 is output. On the other hand, in the method of the present invention, when only one character out of five characters does not match and the other four characters match, 0.8 is output. Also, if 2 characters out of 5 characters match and the other 3 characters do not match, 0
.. 4 is output. If all five characters do not match, 0 is output.

【0018】図6は、本発明の方式の使用例を示す図で
ある。この図において、ファイルAは、プログラムの命
令であり、“aaa”を100回印刷出力することを意
味する。一方、ファイルBも、プログラムの命令であり
、“bbb”を100 回印刷出力することを意味する
。これらのファイルA及びBは、印刷内容である“aa
a”及び“bbb”の部分のみが異なり、他の部分は、
完全に一致している。従来は、ファイルA、Bの2行目
同士は、不一致のものとしてそれぞれ別個の取扱いがさ
れていた。しかしながら、本発明の方式を使用すること
により、例えば、行単位での2つのファイルの比較で、
類似度の高い行同士を効果的に対応づける等の効率的な
取扱いをすることができる。
FIG. 6 is a diagram showing an example of the use of the method of the present invention. In this figure, file A is a program instruction and means to print out "aaa" 100 times. On the other hand, file B is also a program command and means to print out "bbb" 100 times. These files A and B are print contents “aa
Only the “a” and “bbb” parts are different; the other parts are:
They match perfectly. Conventionally, the second lines of files A and B were treated separately as being mismatched. However, by using the method of the present invention, for example, when comparing two files line by line,
It is possible to perform efficient handling such as effectively associating rows with a high degree of similarity.

【0019】[0019]

【発明の効果】以上説明したように、本発明の文字列比
較方式によれば、類似文字列の判定を行なうようにした
ので、次のような効果がある。即ち、文字列が完全に一
致せずに、従来は、不一致とされてしまった場合にも、
両文字列が極めて類似したものであるという判断を行な
うことができ、この判断を基にして種々の処理を行なう
ことが可能となる。
[Effects of the Invention] As explained above, according to the character string comparison method of the present invention, similar character strings are determined, so that the following effects can be obtained. In other words, even if the character strings do not match completely and would have been considered unmatched in the past,
It is possible to determine that both character strings are extremely similar, and it is possible to perform various processes based on this determination.

【図面の簡単な説明】[Brief explanation of the drawing]

【図1】本発明の文字列比較方式の実施例のブロック図
である。
FIG. 1 is a block diagram of an embodiment of a string comparison method of the present invention.

【図2】従来の文字列比較方式の説明図である。FIG. 2 is an explanatory diagram of a conventional character string comparison method.

【図3】文字列探索のアルゴリズムの説明図である。FIG. 3 is an explanatory diagram of a character string search algorithm.

【図4】文字列探索のアルゴリズムの説明図である。FIG. 4 is an explanatory diagram of a character string search algorithm.

【図5】本発明の方式と従来の方式の相違の説明図であ
る。
FIG. 5 is an explanatory diagram of the difference between the method of the present invention and the conventional method.

【図6】本発明の方式の使用例を示す図である。FIG. 6 is a diagram illustrating an example of the use of the method of the present invention.

【符号の説明】[Explanation of symbols]

1  探索手段 2  比較手段 3  類似度計算手段 1 Search means 2 Comparison means 3 Similarity calculation means

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  双方の文字列から各文字を探索する探
索手段と、当該探索手段により探索された両文字を比較
し、一致か不一致かを検出して記憶する比較手段と、当
該比較手段の比較結果に従って双方の文字列の類似度を
計算して出力する類似度計算手段とから成ることを特徴
とする文字列比較方式。
Claim 1: a search means for searching each character from both character strings, a comparison means for comparing both characters searched by the search means, detecting whether they match or not, and storing the result; A character string comparison method comprising a similarity calculation means for calculating and outputting a similarity between both character strings according to a comparison result.
JP3011449A 1991-01-08 1991-01-08 Character string comparison system Pending JPH04279973A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3011449A JPH04279973A (en) 1991-01-08 1991-01-08 Character string comparison system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3011449A JPH04279973A (en) 1991-01-08 1991-01-08 Character string comparison system

Publications (1)

Publication Number Publication Date
JPH04279973A true JPH04279973A (en) 1992-10-06

Family

ID=11778407

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3011449A Pending JPH04279973A (en) 1991-01-08 1991-01-08 Character string comparison system

Country Status (1)

Country Link
JP (1) JPH04279973A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11175557A (en) * 1997-12-16 1999-07-02 Sanyo Electric Co Ltd Information communication terminal
EP1748367A1 (en) * 2005-06-30 2007-01-31 Broadcom Corporation System and method for matching chip and package terminals
JP2009276709A (en) * 2008-05-19 2009-11-26 Fujitsu Ltd Learning support system, program, and learning support method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11175557A (en) * 1997-12-16 1999-07-02 Sanyo Electric Co Ltd Information communication terminal
EP1748367A1 (en) * 2005-06-30 2007-01-31 Broadcom Corporation System and method for matching chip and package terminals
US7338819B2 (en) 2005-06-30 2008-03-04 Broadcom Corporation System and method for matching chip and package terminals
JP2009276709A (en) * 2008-05-19 2009-11-26 Fujitsu Ltd Learning support system, program, and learning support method

Similar Documents

Publication Publication Date Title
JP2790466B2 (en) Character string search method and apparatus
JPH08255176A (en) Method and system for comparison of table of database
JPH024026B2 (en)
JPH04279973A (en) Character string comparison system
JPH0869476A (en) Retrieval system
JP2720590B2 (en) Pattern recognition device
US4332014A (en) Data retrieval system
JP2519245B2 (en) Information retrieval device
JPH02132570A (en) Identifying process system for pattern detail identifying device
JPH0664586B2 (en) String matching method
JPH064600A (en) Method and device for image retrieval
JPH04315260A (en) Character string collating system
JPH06274701A (en) Word collating device
JPH0743942B2 (en) Compound associative memory
JPS583032A (en) Tree structure access processing system
JPS6051979A (en) Pattern matching device
JPH0546666A (en) Information retrieving device
JPS5820075B2 (en) pattern recognition device
JPH05151286A (en) Data display system in cad system
JPH0375869A (en) Character string retrieving method
JPS63170742A (en) Retrieval processing system for common character string
JPS62187930A (en) Retrieval method and its device
JPH10301758A (en) Sort processor
JPH05108719A (en) Information retrieving device
JPH061506B2 (en) Character recognition device