title: How to give Tesseract a word list (.NET wrapper)
body: <p>TLDR; version:</p>
  <p>Does anyone have a working 'bazaar' config for Tasseract using the .NET wrapper that I could see?</p>
  <p>I'm pretty sure that's what I want (only recognise some words from a list), but it doesn't seem to do anything</p>
  <hr />
  <p>I have a pretty short list of possible strings I'm trying to find (1-4 words). The documentation for Tesseract states:</p>
  <blockquote>
  <p>If you want to replace the whole dictionary, you will need to unpack
  the .traineddata file, create a new word-dawg file, and then pack the
  files back into a .traineddata file. See TrainingTesseract for more
  details.</p>
  </blockquote>
  <p>That sounds like what I want! So I look at <a href="https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract" rel="nofollow noreferrer">TrainingTesseract</a> and see:</p>
  <blockquote>
  <p>The traineddata file is simply a concatenation of the input files,
  with a table of contents that contains the offsets of the known file
  types. See ccutil/tessdatamanager.h in the source code for a list of
  the currently accepted filenames.</p>
  </blockquote>
  <p>Great. So how do I go about unpacking this simple concatenation of input files, modifying the content and header and re-packing it, then? :)</p>
  <p><a href="https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#config-files-and-augmenting-with-user-data" rel="nofollow noreferrer">This post</a> appears to be the same question - which involves simply turning off the default dictionary and using user-words instead:</p>
  <blockquote>
  <p>let’s suppose you want to OCR in English, but suppress the normal
  dictionary and load an alternative word list and an alternative list
  of patterns — these two files are the most commonly used extra data
  files.</p>
  <p>If your language pack is in /path/to/eng.traineddata and the hocr
  config is in /path/to/configs/hocr then create three new files:</p>
  <p>/path/to/eng.user-words: -snip</p>
  <p>/path/to/eng.user-patterns: -snip</p>
  <p>/path/to/configs/bazaar: -snip</p>
  <p>Now, if you pass the
  word bazaar as a trailing command line parameter to Tesseract,
  Tesseract will not bother loading the system dictionary nor the
  dictionary of frequent words and will load and use the eng.user-words
  and eng.user-patterns files you provided. The former is a simple word
  list, one per line. The format of the latter is documented in
  dict/trie.h on read_pattern_list().</p>
  </blockquote>
  <p>But having done this it's made no difference at all!</p>
  <p>I'm creating the engine with:</p>
  <pre><code>using (engine = new TesseractEngine(@&quot;C:\src\x\tessdata&quot;, &quot;eng&quot;, EngineMode.Default, @&quot;C:\src\x\tessdata\engine.config&quot;))
  </code></pre>
  <p>Having made a (UTF-8, unix line endings) file engine.config:</p>
  <pre><code>load_system_dawg     F
  load_freq_dawg       F
  user_words_suffix    user-words
  user_patterns_suffix user-patterns
  </code></pre>
  <p>And created eng.user-patterns and eng.user-words (UTF-8, Unix line ending) files alongide the eng.traineddata.</p>