chiark / gitweb /
Change #<thing>#.<ext> filenames to _<thing>.<ext>
authorIan Jackson <ian@liberator.(none)>
Sun, 5 Jul 2009 10:49:13 +0000 (11:49 +0100)
committerIan Jackson <ian@liberator.(none)>
Sun, 5 Jul 2009 10:49:13 +0000 (11:49 +0100)
pctb/Makefile
pctb/README
pctb/README.charset
pctb/README.files
pctb/commod-results-processor
pctb/convert.c
pctb/decode-pctb-marketdata
pctb/dictionary-manager
pctb/ocr.c
pctb/rgbimage.c

index e458c6b20a73090548c47bca3c0cd2cd2cbb3893..8223583a4cbc8fe8aff377be57eedbf51c18bfea 100644 (file)
@@ -48,5 +48,8 @@ clean:
 
 realclean: clean
        rm -f $(TARGETS)
+       rm -f raw.tsv
+       rm -f _pages.ppm _upload-*.html _commodmap.tsv
+       rm -f _master-*.txt _local-*.txt
        rm -f ./#pages#.ppm ./#upload-*#.html ./#commodmap#.tsv
        rm -f ./#master-*#.txt ./#local-*#.txt raw.tsv
index e6d7707616b4049b2f1d40d3e7957fc70e1bf93e..59a3646591e7fa2f4f1e869c71302f87d8a76b2a 100644 (file)
@@ -31,10 +31,10 @@ Setting the operation mode:
 Options to vary the processing:
   --single-page         One screenful, no paging - results will be incomplete
   --quiet               Suppress progress messages
-  --screenshot-file F   Store or read screenshots in F rather than #pages#.pnm
+  --screenshot-file F   Store or read screenshots in F rather than _pages.ppm
   --window-id ID        Specified X window is the YPP client - do not search
   --edit-charset        Enable character set editing.  See README.dictionary.
-  --no-edit-charset     Do not edit charset even if #local-char*#.txt exists.
+  --no-edit-charset     Do not edit charset even if _local-char*.txt exists.
   --find-island         Find and print the ocean and island.  Suppresses OCR
                          and output unless used with result processing option.
   --test-servers        Set default servers to be the test servers, not
@@ -103,7 +103,7 @@ Reporting problems
 If you need to report a bug, for example an inability to recognise,
 please be sure to remember the exact error message and circumstances.
 Also, for recognition problems there will probably be a very useful
-screenshot file called `#pages#.pnm'.  This is likely to be very large
+screenshot file called `_pages.ppm'.  This is likely to be very large
 so don't just email it to me, but if you can put it up on a webpage
 for me to download that will help.  At least keep a copy of it.
 
@@ -111,7 +111,7 @@ If the problem is a failure to cope with some particular YPP client
 display and is reproducible, try running:
    ./ypp-commodities --raw-tsv --single-page
 If this reproduces the problem, please email me the screenshot file
-#pages#.pnm, which will consist only of the single screen, plus the
+_pages.ppm, which will consist only of the single screen, plus the
 error messasge.  I'll then be able to understand what's wrong,
 hopefully.
 
index 25eb5d88feb9e6d8ad603533610219eb34c682b5..770d3f3c29313a6b4d6c30f936e7fe7ecc6952e9 100644 (file)
@@ -140,17 +140,17 @@ errors.
 
 If you think you have made mistakes answering OCR queries (for
 example, the recognised data is wrong), you should delete the file
-#local-char*#.txt, which contains your local updates.  It will then
+_local-char*.txt, which contains your local updates.  It will then
 only use the centrally provided (and vetted) master file (which is
 automatically updated when you run the PCTB client, by default).
 
 It is also possible to have the OCR system reject particular strings.
-If you put a regexp in #local-reject#.txt, any OCR result which
+If you put a regexp in _local-reject.txt, any OCR result which
 matches this string will instead cause an OCR failure, invoking the
-OCR dictionary editor if appropriate.  #master-reject#.txt is the
+OCR dictionary editor if appropriate.  _master-reject.txt is the
 centrally maintained version of this file.
 
-Alternatively you can edit #local-char15#.txt with a text editor.  The
+Alternatively you can edit _local-char*.txt with a text editor.  The
 format is not documented at the moment.
 
 
@@ -161,7 +161,7 @@ Now that you have read this document, you should rerun your OCR job
 with the --edit-charset option.  So run
     ./ypp-commodities --edit-charset
 In future, this option is not usually needed, because it is the
-default if there is a local character set dictionary #local-<h>#.txt
+default if there is a local character set dictionary _local-<h>.txt
 for the relevant character height.
 
 With --edit-charset, when the OCR finds characters it does not
index 254217a6d58e6200b0fb8007d781c451ad076332..b2384a1125b572defc47823dfa6eab3a3b550748 100644 (file)
@@ -3,7 +3,7 @@ Files we use and update
 
 The program reads and writes the following files:
 
- * #pages#.pnm
+ * _pages.ppm
 
    Contains one or more images (as raw ppms, end-to-end) which are the
    screenshots taken in the last run.  This is (over)written whenever
@@ -14,10 +14,10 @@ The program reads and writes the following files:
    You can specify a different file with --screenshot-file.
 
    If you want to display the contents of this file, `display' can do
-   it.  Don't try `display vid:#pages#.pnm' as this will consume
+   it.  Don't try `display vid:_pages.ppm' as this will consume
    truly stupendous quantities of RAM - it wedged my laptop.
 
- * #master-newcommods#.txt #local-newcommods#.txt
+ * _master-newcommods.txt _local-newcommods.txt
 
    Dictionary of newly introduced commodities.  When a new commodity
    appears in Puzzle Pirates, the PCTB server operators need to add it
@@ -35,7 +35,7 @@ The program reads and writes the following files:
    double-check what you're doing before overriding the uploader by
    telling it to ignore an unrecognised commodity.
 
- * #master-reject#.txt #local-reject#.txt
+ * _master-reject.txt _local-reject.txt
 
    Dictionary of regexps which, when the OCR appears to match, we
    reject instead.  At the moment this is used to stop us thinking
@@ -43,41 +43,41 @@ The program reads and writes the following files:
    character set dictionary is missing the lowercase `y ' glyph.
    See README.charset.
 
- * #master-char*#.txt  #local-char*#.txt
-   #master-pixmap#.txt #local-pixmap#.txt
+ * _master-char*.txt  _local-char*.txt
+   _master-pixmap.txt _local-pixmap.txt
 
    Character set and image dictionaries.  For the semantics of the
    char* files README.charset.  There is not currently any accurate
    documentation of this dictionary format.
 
-   #master-*#.txt contain the centrally defined and approved data.
+   _master-*.txt contain the centrally defined and approved data.
    They are downloaded automatically from the SC PCTB server and
    updated each run.  You can safely delete this file, if everything
    is online, if you want to fetch a fresh copy.
 
-   #local-*#.txt are a local copy of your submissions, so that they
+   _local-*.txt are a local copy of your submissions, so that they
    will be used by your client pending approval by me.  You can delete
    this file if you think you may have made a mistake.
 
    See README.privacy for details of the communications with the SC
    server about the contents of these dictionaries.
 
- * #commodmap#.tsv
+ * _commodmap.tsv
 
    Map from commodity names to the numbers required by the PCTB
    server.  This is fetched and updated automatically as necessary.
    It can safely be deleted as it will then be refetched.
 
- * #upload-1#.html #upload-2#.html
+ * _upload-1.html _upload-2.html _upload-3.html
 
    We screenscrape the pages from the PCTB upload server.  The actual
    HTML returned from the upload server is left in these dropping
    files for debugging etc.
 
- * <file>.tmp
+ * _<file>.tmp
 
    When any of these tools overwrite one of the persistent dictionary
-   files, they temporarily write to <file>.tmp.  We also use a couple
+   files, they temporarily write to _<file>.tmp.  We also use a couple
    of other temporary files.
 
 Future versions may have more helpers and more data files.
index e391e4749780c1a04e50abfc4f146a4317a3b771..4a70ddf7767376ab8b9db5406750c257460e9c3c 100755 (executable)
@@ -224,7 +224,7 @@ our ($ua)= LWP::UserAgent->new;
 
 sub load_commodmap() {
     undef %commodmap;
-    my $c= new IO::File "#commodmap#.tsv";
+    my $c= new IO::File "_commodmap.tsv";
     if (!$c) { $!==&ENOENT or die $!; return; }
     while (<$c>) {
        m/^(\S.*\S)\t(\d+)\n$/ or die "$_";
@@ -244,7 +244,7 @@ sub refresh_commodmap() {
     my $incommodmap=0;
     my $intag='';
     my %got;
-    my $o= new IO::File "#commodmap#.tsv.tmp",'w' or die $!;
+    my $o= new IO::File "_commodmap.tsv.tmp",'w' or die $!;
     undef %commodmap;
 
     my $xp= new XML::Parser
@@ -292,7 +292,7 @@ sub refresh_commodmap() {
 #    print STDERR "[[[$content]]]\n";
     $xp->parse($content);
     close $o or die $!;
-    rename "#commodmap#.tsv.tmp","#commodmap#.tsv" or die $!;
+    rename "_commodmap.tsv.tmp","_commodmap.tsv" or die $!;
 }
 
 our %newcommods;
@@ -317,7 +317,7 @@ sub refresh_newcommods() {
     my $rsync= $ENV{'YPPSC_PCTB_RSYNC'};
     $rsync= 'rsync' if !defined $rsync;
 
-    my $local= "#master-newcommods#.txt";
+    my $local= "_master-newcommods.txt";
     my $src= $ENV{'YPPSC_PCTB_DICT_UPDATE'};
     if ($src) {
        my $remote= "$src/master-newcommods.txt";
@@ -325,7 +325,7 @@ sub refresh_newcommods() {
        die "$? $!" if $! or $?;
     }
     read_newcommods($local);
-    read_newcommods('#local-newcommods#.txt');
+    read_newcommods('_local-newcommods.txt');
 }
 
 our (%stallmap, @stallmap);
@@ -430,7 +430,7 @@ sub main__genmarketdata () {
 
 sub save_upload_html ($$) {
     my ($which, $resptxt) = @_;
-    open R, ">./#upload-$which#.html" or die $!;
+    open R, ">./_upload-$which.html" or die $!;
     print R $resptxt or die $!;
     close R or die $!;
 }
@@ -458,7 +458,7 @@ sub main__upload () {
     my $resptxt= $resp->content();
     save_upload_html('1', $resptxt);
 
-    open R, ">./#upload-1#.html" or die $!;
+    open R, ">./_upload-1.html" or die $!;
     print R $resptxt or die $!;
     close R or die $!;
 
@@ -514,7 +514,7 @@ sub main__upload () {
     save_upload_html('3', $resptxt);
 
     print "\n" or die $!;
-    system('w3m -T text/html -dump < \#upload-3#.html');
+    system('w3m -T text/html -dump < _upload-3.html');
     
     print "\n" or die $!;
 }
index 3c5af994c3f7c9db88c8cc22875b7979f6384bad..9531da02626dfbd624135de41daaaab43ddbc8e9 100644 (file)
@@ -125,7 +125,7 @@ void fetch_with_rsync(const char *stem) {
   
     const char *src= getenv("YPPSC_PCTB_DICT_UPDATE");
     char *remote= masprintf("%s/master-%s.txt", src, stem);
-    char *local= masprintf("#master-%s#.txt", stem);
+    char *local= masprintf("_master-%s.txt", stem);
     if (DEBUGP(rsync))
       fprintf(stderr,"executing rsync to fetch %s to %s\n",remote,local);
     execlp(rsync, "rsync",
@@ -267,7 +267,7 @@ int main(int argc, char **argv) {
             o_serv_dict_submit,  o_flags & ff_dict_submit);
 
   if (!o_screenshot_fn)
-    o_screenshot_fn= masprintf("%s/#pages#.ppm",get_vardir());
+    o_screenshot_fn= masprintf("%s/_pages.ppm",get_vardir());
 
   /* Actually do the work */
             
index d798aad03a1e8de8bc274e5de9837c5635801848..0c0fe38fe4948ba545f9d56338784f3342d40a82 100755 (executable)
@@ -2,7 +2,7 @@
 
 use IO::Handle;
 
-open CM, "#commodmap#.tsv" or die $!;
+open CM, "_commodmap.tsv" or die $!;
 
 $debug=1 if @ARGV;
 
index 19e067c93ba188a21222cb8411845ce19ef13b14..2c91a2a372be1a9cac3b5e5482b59bdfad8e51bd 100755 (executable)
@@ -95,7 +95,7 @@ proc bgerror {m} {
 }
 
 proc execpnm_createphoto {photoname args} {
-    set tmpfile ./#dictimage#.tmp
+    set tmpfile ./_dictimage.tmp
     eval exec $args > $tmpfile
     image create photo $photoname -file $tmpfile
     file delete $tmpfile
@@ -257,7 +257,7 @@ proc write_database {} {
 proc select_database {dbname_spec} {
     global dbname
     set dbname $dbname_spec
-    read_database "./#local-$dbname#.txt"
+    read_database "./_local-$dbname.txt"
 }
 
 proc do_database_update {im def} {
index 8d1b88bbf1f20f35e992c82cbf357ecb1385800b..37ca7d28ed284de9b70c1cc29b1f528a20d24a12 100644 (file)
@@ -122,7 +122,7 @@ static void readdb1(OcrReader *rd, const char *which, int local) {
   int h, endsword;
   char lbuf[100];
 
-  char *dbfname= masprintf("%s/#%s-char%d#.txt",
+  char *dbfname= masprintf("%s/_%s-char%d.txt",
                           get_vardir(), which, rd->h);
   
   if (!dbfile_open(dbfname))
@@ -238,7 +238,7 @@ Rejection *rejections;
 
 static void load_rejections(const char *which) {
   char lbuf[1000];
-  char *fname= masprintf("%s/#%s-reject#.txt", get_vardir(), which);
+  char *fname= masprintf("%s/_%s-reject.txt", get_vardir(), which);
   int c, lno=0;
   Rejection *rej;
   
@@ -649,7 +649,7 @@ void ocr_showcharsets(void) {
 
   memset(found,0,sizeof(found));
   
-  fnpat= pcre_compile("\\#(?:master|local)\\-char([1-9]\\d{0,2})\\#\\.txt$",
+  fnpat= pcre_compile("_(?:master|local)\\-char([1-9]\\d{0,2})\\.txt$",
                      PCRE_ANCHORED|PCRE_DOLLAR_ENDONLY,
                      &pcre_err,&pcre_erroffset, 0);
   debugf("pcre_compile %p %s\n",fnpat,pcre_err);
index 0e89892306605d0b9f5e14773125197f7445e234..dfcd1808f25421ceb9223343c1d24618bbae2eef 100644 (file)
@@ -51,7 +51,7 @@
 static int identify1(const RgbImage *base, Rect portion,
                    char result[MAXIMGIDENT], const char *what,
                    const char *which) {
-  char *dbfile_name= masprintf("#%s-pixmap#.txt",which);
+  char *dbfile_name= masprintf("_%s-pixmap.txt",which);
   if (!dbfile_open(dbfile_name))
     goto not_found;