]> git.donarmstrong.com Git - infobot.git/commitdiff
web1913
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 22 Feb 2005 22:25:26 +0000 (22:25 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 22 Feb 2005 22:25:26 +0000 (22:25 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1167 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/Modules/Dict.pl

index c254d05e151aa8ad4f613e672d1107ad90e5df69..71acb5af60ecb2b87590873fe14db1e198c823fd 100644 (file)
@@ -57,11 +57,13 @@ sub Dict {
        # body.
        push(@results, &Dict_Wordnet($socket,$query));
        push(@results, &Dict_Foldoc($socket,$query));
+       push(@results, &Dict_web1913($socket,$query));
        # end.
 
        print $socket "QUIT\n";
        close $socket;
 
+       &::DEBUG(join(";;\n",@results));
        my $total = scalar @results;
 
        if ($total == 0) {
@@ -106,7 +108,7 @@ sub Dict_Wordnet {
        chop;   # remove \n
        chop;   # remove \r
 
-       &::DEBUG("got '$_'");
+       &::DEBUG("wordnet '$_'");
        if (/^552 no match/) {
            # no match.
            return;
@@ -157,7 +159,7 @@ sub Dict_Foldoc {
        chop;   # remove \n
        chop;   # remove \r
 
-       &::DEBUG("got '$_'");
+       &::DEBUG("foldoc '$_'");
        if (/^552 /) {
            # no match
            return;
@@ -196,4 +198,55 @@ sub Dict_Foldoc {
     return @results;
 }
 
+sub Dict_web1913 {
+    my ($socket,$query) = @_;
+    my @results;
+
+    &::status("Dict: asking web1913.");
+    print $socket "DEFINE web1913 \"$query\"\n";
+
+    my $string;
+    while (<$socket>) {
+       # remove \n
+       chop;
+       # remove \r
+       chop;
+       &::DEBUG("web1913 '$_'");
+
+       # no match.
+       return if /^552/;
+
+       # stats; end of def.
+       last if (/^250/);
+
+       # definition and/or retrieval
+       next if (/^151/ or /^150/);
+
+       # each line.
+       s/^\s+|\s+$//g;
+
+       # sub def separator.
+       if ($_ eq "" or $_ =~ /^\.$/) {
+           # sub def.
+           $string =~ s/^\s+|\s+$//g;
+           $string =~ s/[{}]//g;
+
+           next if ($string eq "");
+
+           push(@results, $string);
+           $string = "";
+       }
+
+       $string .= $_." ";
+    }
+
+    &::status("Dict: web1913: found ". scalar(@results) ." defs.");
+
+    return if (!scalar @results);
+    # last def is date of entry.
+    #pop @results;
+
+    return @results;
+}
+
 1;