#
# CHISE.pm by Shigeki Moro
-# $Id: CHISE.pm,v 1.2 2003-02-23 09:17:19 moro Exp $
+# $Id: CHISE.pm,v 1.3 2003-03-12 16:53:59 moro Exp $
#
package CHISE;
use strict;
use BerkeleyDB;
+our ($EXCLUSIVE, $HAVE_INTERSECTION, $PROPER_SUBSET, $PROPER_SUPERSET, $EQSET);
+($EXCLUSIVE, $HAVE_INTERSECTION, $PROPER_SUBSET, $PROPER_SUPERSET, $EQSET)
+ = (1, 2, 3, 4, 5);
+
my $DB_HOME = '/usr/local/lib/xemacs-21.4.10/i686-pc-linux/char-db';
my %alias = ();
#}
sub compare {
- # 字オブジェクトと比
+ # 字オブジェクトどうしを比して、
+ # 合の重なり具合をす。
+ my($a, $b) = @_;
+ my($aonly, $bonly, $common) = (0, 0, 0);
+ for my $i (&cup(keys %$a, keys %$b)) {
+ if ($a->{$i} eq $b->{$i}) {
+ $common++;
+ } else {
+ $aonly++ if (exists $a->{$i});
+ $bonly++ if (exists $b->{$i});
+ }
+ }
+ if ($common == 0) {
+ return $EXCLUSIVE; # 他
+ } elsif ($aonly == 0 and $bonly == 0) {
+ return $EQSET; # 全一致
+ } elsif ($aonly == 0) {
+ return $PROPER_SUBSET; # $aは$bの合
+ } elsif ($bonly == 0) {
+ return $PROPER_SUPERSET; # $bは$aの合
+ } else {
+ return $HAVE_INTERSECTION;
+ }
+}
+
+sub rate_of_coincidence {
+ # 字オブジェクトどうしの属性の一致を出す。
my($a, $b) = @_;
my($all_attr, $common_attr) = (0, 0);
for my $i (&cup(keys %$a, keys %$b)) {