An unfinished system to manage all your paper documentation in an easy way.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/perl
  2. use strict;
  3. use lib '/opt/autodoc/lib';
  4. use Autodoc;
  5. use utf8;
  6. use warnings;
  7. $|=1;
  8. my $conf = load_conf("../etc/autodoc.json");
  9. my $dbh = sqlconnect($conf->{sql});
  10. my $chunk = 10000;
  11. my %lang = (
  12. 'fr' => [ 'french' ],
  13. 'de' => [ 'swiss', 'ngerman' ],
  14. 'en' => [ 'british-english-large', 'american-english-large' ],
  15. 'it' => [ 'italian' ],
  16. );
  17. foreach my $lang ( sort keys %{$conf->{dict}} ) {
  18. print "Loading language $lang ...\n";
  19. foreach my $dict ( @{$conf->{dict}{$lang}} ) {
  20. my $file = '/usr/share/dict/'.$dict;
  21. my @words;
  22. open(DICT, $file) || die "Failed to load $file, did you install the required dictionaries?";
  23. while(<DICT>) { chomp; push @words, $_; }
  24. close(DICT);
  25. my $len = scalar(@words);
  26. for(my $pos = 0; $pos < $len; $pos+=$chunk) {
  27. my @query;
  28. my @args;
  29. for(my $i=0; $i<$chunk && defined $words[$pos+$i]; $i++) {
  30. push @args, $words[$pos+$i];
  31. push @args, $lang;
  32. push @query, "(?,?)";
  33. }
  34. my $query = "INSERT IGNORE INTO dict" .
  35. "(word, lang) VALUES " .
  36. join(",",@query);
  37. sqlquery($dbh, $query, @args);
  38. my $cnt = $pos + (scalar(@args)/2);
  39. printf("\t%s %s/%s (%i%%) \r",
  40. $dict, $cnt , $len, int($cnt/$len*100) );
  41. }
  42. printf("\n");
  43. }
  44. }