|
| 1 | +.. _cli-scancode-train-gibberish-model: |
| 2 | + |
| 3 | +ScanCode train gibberish model |
| 4 | +============================== |
| 5 | + |
| 6 | +ScanCode uses a 2-character Markov chain to perform gibberish detection on text. |
| 7 | +At a high level, it detects gibberish strings by seeing if a sequence of letters |
| 8 | +is part or a whole word, two letters at a time. It does this by checking how |
| 9 | +likely it is to go from one letter to another. The probabilities of going from |
| 10 | +one letter to another are determined by a model that has been trained on a large |
| 11 | +set of valid text, where it counts each transition between letters and computes |
| 12 | +a probability based off of that. These probabilities and thresholds are stored |
| 13 | +in a model that is saved to a Python pickle. |
| 14 | + |
| 15 | +The training corpus for the gibberish detector can be found in |
| 16 | +``src/textcode/data/gibberish/``. |
| 17 | + |
| 18 | +``big.txt`` contains the main source of valid words that the gibberish detector |
| 19 | +model is trained on. |
| 20 | + |
| 21 | +``good.txt`` and ``bad.txt`` are used to determine the average threshold, where |
| 22 | +any letter transition whose average transition probability falls below this |
| 23 | +threshold is classified as gibberish. |
| 24 | + |
| 25 | + |
| 26 | +Usage: ``scancode-train-gibberish-model [OPTIONS]`` |
| 27 | + |
| 28 | +Quick Reference |
| 29 | +--------------- |
| 30 | + |
| 31 | + --big FILE Text file containing main training corpus for the gibberish |
| 32 | + detector |
| 33 | + --good FILE Text file containing text considered to be not gibberish (good) |
| 34 | + --bad FILE Text file containing text considered to be gibberish (bad) |
| 35 | + -h, --help Show this message and exit. |
| 36 | + |
| 37 | +---- |
| 38 | + |
| 39 | +.. _cli-scancode-train-gibberish-model-big-option: |
| 40 | + |
| 41 | +``--big`` option |
| 42 | +^^^^^^^^^^^^^^^^ |
| 43 | + |
| 44 | +The ``--big`` option allows the user to use a different text file to train the |
| 45 | +gibberish detector model. |
| 46 | + |
| 47 | +.. _cli-scancode-train-gibberish-model-good-option: |
| 48 | + |
| 49 | +``--good`` option |
| 50 | +^^^^^^^^^^^^^^^^^ |
| 51 | + |
| 52 | +The ``--good`` option allows the user to use a different text file containing |
| 53 | +strings considered to be valid copyrights. This option is used to adjust the |
| 54 | +average transition probability threshold that determines whether or not a string |
| 55 | +is gibberish. |
| 56 | + |
| 57 | +.. _cli-scancode-train-gibberish-model-bad-option: |
| 58 | + |
| 59 | +``--bad`` option |
| 60 | +^^^^^^^^^^^^^^^^ |
| 61 | + |
| 62 | +The ``--bad`` option allows the user to use a different text file containing |
| 63 | +strings considered to be invalid copyrights. This option is used to adjust the |
| 64 | +average transition probability threshold that determines whether or not a string |
| 65 | +is gibberish. |
0 commit comments