Code Search for Developers
 
 
  

fix_spelling.html from AlphaMail at Krugle


Show fix_spelling.html syntax highlighted

% # vim:set syntax=mason:
<%init>
my $user = Apache::SiteControl->getCurrentUser($r);
my $username = $user->getUsername();
my $logger = Log::Log4perl->get_logger('alphamail');
my $error = 0;
my $speller = new Text::Aspell;
$speller->set_option("lang", "en_US");
$speller->set_option("sug-mode", "fast");

$logger->debug("Fixing spelling.");
# Load the message from the session.
my $composition = load_composition($r, $user);
my $message = $composition->{message};

my (@lines, $i, $s, $e, $v, @nearmisses, @fixes, $html, $box, $word);

@lines = split /\r?\n/, $message;
$message = "";
for($i = 0; $i <= $#lines; $i++) {
   $v = $lines[$i];
   chomp $v;
   @fixes = ();
   # Find the original mistakes
   while(scalar($v =~ m/([-a-z]+)/ig)) {
      $word = $1;
      $s = pos($v) - length($word);
      $e = pos($v) - 1;
      if(!$speller->check($word)) {
         @nearmisses = $speller->suggest($word);
         push @fixes, { a => $s, b => $e, word => $word };
      } 
   }

   # Fix the line from R to L (using choices from incoming args)
   @fixes = sort { $b->{a} <=> $a->{a} } @fixes;
   my $text = $v;
   for my $fix (@fixes) 
   {
      my $cname = "c_${i}_$fix->{a}_$fix->{b}";
      if(!defined($ARGS{$cname})) {
         $logger->error("Missing incoming selection for $cname");
         $text = substr($text, 0, $fix->{a}) . $fix->{word} . substr($v, $fix->{b}+1,length($text) - $fix->{b});
         next;
      } else {
         $text = substr($text, 0, $fix->{a}) . $ARGS{$cname} . substr($text, $fix->{b}+1,length($text) - $fix->{b});
      }
   }
   $message .= "$text\n";
}

save_composition($r, $user, $composition->{to}, $composition->{cc}, 
   $composition->{bcc}, $composition->{subject}, $message,
   $composition->{replyflag}, $composition->{forwardflag}, 
   $composition->{"ref"}, $composition->{attachments}, $composition->{sizes},
   $composition->{richtext});

$m->redirect("/mail/compose.html");
</%init>
<%once>
use AlphaMail::SessionUtil qw(save_composition load_composition clear_composition);
use Text::Aspell;
</%once>




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  addressbook/
    edit.mhtml
    import.mhtml
    import_alias.html
    import_complete.html
    import_csv.html
    import_csv_save.html
    import_fname.html
    import_imho.html
    import_lname.html
    index.html
    process_edit.html
    take.html
  settings/
    altfolder_update.html
    edit_folders.html
    folders.mhtml
    general.mhtml
    index.html
    share.mhtml
    sharing_agree.html
    signatures.mhtml
    update_folderlist.html
    update_general.html
    update_signatures.html
  viewers/
    excel.html
    html.html
    targz.html
    word.html
    zip.html
  address_mail.html
  addresslist.mhtml
  autohandler
  check_spelling.html
  compose.html
  filevault.html
  first_login.html
  fix_spelling.html
  folderlist.mhtml
  footer.mhtml
  get_attachment.html
  header.mhtml
  index.html
  logout.html
  menu.mhtml
  other_folders.html
  print.html
  process_compose.html
  process_first_login.html
  process_messages.html
  read.html
  remove_attachment.html
  renew_session.html
  share_options.html
  share_upload.html
  verify_password.html
  view_attachment.html