validator/httpd/cgi-bin check,1.695,1.696

Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv12235/httpd/cgi-bin

Modified Files:
	check 
Log Message:
Remove fuzzy matching/"Did you mean ..." implementation due to too many
incorrect suggestions emitted.  We'd need to be aware of which attributes
and/or elements are valid in the checked document in the particular position;
flat lists of all HTML elements and attributes results in too many false
positives.  String::Approx usage would have probably needed some work as
well, or perhaps it wasn't the best choice for the task to begin with.


Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.695
retrieving revision 1.696
diff -u -d -r1.695 -r1.696
--- check	16 Sep 2009 17:32:07 -0000	1.695
+++ check	16 Sep 2009 19:15:19 -0000	1.696
@@ -64,7 +64,6 @@
 use URI                        qw();
 use URI::Escape                qw(uri_escape);
 use XML::LibXML                qw();
-use String::Approx             qw();
 
 ###############################################################################
 #### Constant definitions. ####################################################
@@ -3122,58 +3121,6 @@
     # in that case the error message will be #344
   }
 
-  if ( ($err->{num} eq '108') or ($err->{num} eq '76') )
-  # element or attribute does not exist? Let's try and fuzzy-match it
-  {
-      my $bogus_elt_attr = $err->{msg};
-      $bogus_elt_attr =~ s/.*"(.+)".*/$1/;
-      if ($err->{num} eq '108') {
-          $err->{msg} = "Attribute \"".$bogus_elt_attr."\" is not a valid attribute";
-      }
-
-      if(($err->{num} eq '108') and
-         (exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and
-         (!$is_xml || $bogus_elt_attr eq lc($bogus_elt_attr))) {
-          # attribute not available in this context.
-          $err->{msg} = "Attribute \"$bogus_elt_attr\" can not be used for this element.";
-      }
-      elsif ( (
-             ((exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and ($err->{num} eq '108'))
-           or
-             ((exists $self->{CFG}->{Elements}->{lc($bogus_elt_attr)}) and ($err->{num} eq '76'))
-          )
-          and (lc($bogus_elt_attr) ne $bogus_elt_attr)
-        )
-      {
-          $err->{msg} .= '. Did you mean "'.lc($bogus_elt_attr).'"?';
-      }
-      else { #fuzzy-match and suggest alternatives
-          my @matches;
-          if ($err->{num} eq '108') {
-              @matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Attributes}});
-          }
-          elsif ($err->{num} eq '76') {
-              @matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Elements}});
-          }
-          if (@matches){
-              my %distances;
-              @distances{@matches} = map { abs } String::Approx::adist(lc($bogus_elt_attr), @matches);
-              my @matches_sorted = sort { $distances{$a} <=> $distances{$b} } @matches;
-              # a bit of printf debugging can't hurt
-              # foreach my $match (@matches_sorted) {
-              #     $err->{msg} .= '<br /> match '.$match.': '.$distances{$match};
-              # }
-               if (@matches > 1){
-                  $err->{msg} .= '. Did you mean "'.$matches_sorted[0].'" or "'.$matches_sorted[1].'"?';
-
-              }
-              else {
-                  $err->{msg} .= '. Did you mean "'.$matches_sorted[0].'"?';
-              }
-          }
-      }
-  }
-
    if (($err->{num} eq '113') and ($err->{msg} =~ /xml:space/)) {
      # FIXME
      # this is a problem with some of the "flattened" W3C DTDs, filtering them out to not confuse users.

Received on Wednesday, 16 September 2009 19:15:32 UTC