chiark / gitweb /
wip matching context selection
[ypp-sc-tools.db-live.git] / pctb / README.charset
1 Handing OCR failures
2 --------------------
3
4 Sometimes the OCR will not be able to recognise some text.  By
5 default, when this happens, the program will stop with a fatal error
6 and refer you to this document.
7
8 It is possible to fix this by editing the character set dictionary used
9 by the OCR algorithm.  But, it is important to get these inputs right
10 or your client may misrecognise text in future.  You *must* read the
11 documentation here first.
12
13
14 Recognition algorithm
15 ---------------------
16
17 We recognise the text in the commodity screen by doing exact matching
18 of `glyph' bitmaps, against the bitmap in each cell in the commodity
19 table.  We match from left to right.
20
21 We do not insist that each glyph is followed by whitespace, and nor do
22 we insist that glyphs do not contain whitespace.  Our glyph dictionary
23 can contain entries which are strict prefixes of other entries - that
24 is, a glyph for (say) `v' which is the leftmost part of another glyph
25 for (say) `w'.  We resolve these ambiguities by taking the longest
26 (widest) glyph which matches.
27
28 So you should not be surprised if the program has matched the
29 left-hand half of some letter and thinks it is a different letter.  If
30 the part that it did recognise does look like the letter in question,
31 that isn't wrong.  All you need to do is insert the whole of the
32 actual letter in the dictionary - move the LH cursor to the start of the
33 letter, and the RH cursor to its end, and hit `return' and enter the
34 correct character.  The longest match rule will mean it will prefer
35 the entry you have just made.
36
37
38 Upper vs lower case - important note regarding `l' and `I'
39 ----------------------------------------------------------
40
41 We maintain separate dictionaries for upper case (Upper), lower case
42 (Lower), and (initial portions of) mid-phrase words (Word).  At the
43 beginning of each cell in the table, we expect uppercase; in the
44 middle of a word we expect lowercase; and, unfortunately, after an
45 inter-word gap, we are not sure.
46
47 This is troublesome because `l' and `I' look identical on the screen.
48 So any time we see a word starting with `l' or `I', the program has to
49 ask about it.
50
51 After an interword gap, we first search for a Word entry in the
52 dictionary.  If there is a match we use it.  Otherwise we search both
53 the uppercase and lowercase dictionaries; if one matches and the other
54 doesn't, or one matches a wider character than the other, we use it.
55 If that fails to resolve the ambiguity we must ask.
56
57 *Do not* make an entry in the character set dictionary mapping `vertical
58 stick' to `l' or `I'.  Instead, select enough of the whole word in
59 question that no word would start with the other letter, and enter the
60 whole word or part of it as a new glyph as a new Word.
61
62 For example, in the supplied dictionary there is already a glyph for
63 `Iron'; this is OK because there are no words which start `lron'.
64
65
66 Short inter-word gaps
67 ---------------------
68
69 It can happen that the problem you are being asked about is caused by
70 the program failing to spot an inter-word gap and mistakenly thinks
71 that the next word is necessarily in lowercase, so fails to recognise
72 an uppercase letter.  The context in which each glyph was recognised
73 is shown on the screen, underneath the text which shows what it was
74 recognised as.
75
76 *You should check the alleged context before entering a character*.
77 If it is wrong, you should fix it, rather that just making an entry
78 for the uppercase letter in the lowercase dictionary.
79
80 Instead, make a new glyph for the last letter of the previous word
81 plus the (unusually narrow) inter-word space, and end that entry with
82 a literal space ` '.
83
84 For example, you might find that `y<space>G' is treated as
85 `y<??lowercase>' and the G doesn't get matched.  Select the `y<space>'
86 region of the bitmap and type `y ' into the string box.
87
88
89 Overlapping characters - ligatures
90 ----------------------------------
91
92 Some of the characters in the font used overlap with the next
93 character.  When this happens, select both the characters and enter
94 them together as one glyph with a multi-character definition.
95
96 For example `yw' is rendered with the top right corner of the `y' and
97 the top left corner of the `w' overlapping.  This is dealt with by
98 matching the whole merged thing - select the region of the screen
99 containing `yw' and define it as `yw'.
100
101
102 Fixing mistakes
103 ---------------
104
105 The OCR query UI allows you to delete things from the glyph
106 dictionary.  However since you are not guaranteed to actually get an
107 OCR query at all (and since it is not possible to override the
108 presence of an entry in the master database with the absence of one in
109 the local database), if the dictionary contains errors, you shouldn't
110 rely on this.
111
112 If you think you have made mistakes answering OCR queries (for
113 example, the recognised data is wrong), you should delete the file
114 #local-char*#.txt, which contains your local updates.  It will then
115 only use the centrally provided (and vetted) master file (which is
116 automatically updated when you run the PCTB client, by default).
117
118
119 Enabling interactive character set update
120 -----------------------------------------
121
122 Now that you have read this document, you should rerun your OCR job
123 with the --edit-charset option.  You probably want to supply --same as
124 well, to avoid having to wait for it to page through and recapture all
125 the screenshots.  So, this time,
126    ./ypp-commodities --edit-charset --same
127 and in future, just always run it with the --edit-charset option.
128
129 With --edit-charset, when the OCR finds characters it does not
130 understand, it will put up an OCR resolution query window.  This will
131 display the part of the text it is having trouble with, showing where
132 it has got to, and allow you to edit the character set dictionary it
133 uses for recognising the text.
134
135 *This is subtle* and it is important to understand the way the
136 machinery works, and the possible mistakes you can make, before
137 answering the program.  *Please read this documentation*, which
138 explains the meaning of the entries you make.
139
140 Also, the character set updates you make will by default be submitted
141 to my server so that they can be checked by me and shared with other
142 users.  See README.privacy.
143
144 If you need help please ask me (ijackson@chiark.greenend.org.uk, or
145 Aristarchus on Midnight in game if I'm on line, or ask any pirate of
146 the crew Special Circumstances if they happen to know where I am
147 and/or can get in touch).