Skip to main content

Fuzz a language by mixing up only few words.

Project description

afasi

license version downloads wheel supported-versions supported-implementations

Fuzz a language by mixing up only few words.

Status

Beta.

Note: The default branch is default.

Use

  • Examples
    • Version
    • General Help
    • Translate Help
    • Translate Dryrun
    • Translate
    • Example Translation Tables
  • Command Line API
  • afasi
    • afasi template
    • afasi translate
    • afasi version

Examples

Version

$ afasi version
Fuzz a language by mixing up only few words. version 2021.10.22

General Help

$ afasi
Usage: afasi [OPTIONS] COMMAND [ARGS]...

  Fuzz a language by mixing up only few words.

  The translation table entries are applied in order per line of input. So,
  with large translation tables the performance will obviously degrade with a
  power of two. The latter should be taken as a hint to maintain both language
  files in separate entities not as a patch task.

  The translation table is either an array of two element arrays provided as
  JSON and thus shall be in a shape like:

    [
      ["repl", "ace"],
      ["als", "othis"]
    ]

  Or the table is given as an object providing more detailed instructions
  constraining the translation rules like:

  * contra indicators - when given exempting a line from translation
  * pro indicators - when given marking a line for translation
  * flip_flop indicators - providing either stop-start (default) or start-stop state switching

  The JSON object format is best understood when executing the template
  command and adapting the resulting JSON object written to standard out.

  Default for input source is standard in and out per default is sent to
  standard out.

Options:
  -V, --version  Display the afasi version and exit
  -h, --help     Show this message and exit.

Commands:
  template   Write a template of a translation table JSON structure to...
  translate  Translate from a language to a 'langauge'.
  version    Display the afasi version and exit

Translate Help

$ afasi translate -h
Usage: afasi translate [OPTIONS] [SOURCE] [TARGET]

  Translate from a language to a 'langauge'.

Arguments:
  [SOURCE]  [default: STDIN]
  [TARGET]  [default: STDOUT]

Options:
  -i, --input <sourcepath>        Path to input file (default is reading from
                                  standard in)
  -o, --output <targetpath>       Path to non-existing output file (default is
                                  writing to standard out)
  -t, --table <translation table path>
                                  Path to translation table file in JSON
                                  format. Structure of table data is [["repl",
                                  "ace"], ["als", "othis"]]
  -n, --dryrun                    Flag to execute without writing the
                                  translation but a diff instead (default is
                                  False)
  -h, --help                      Show this message and exit.

Translate Dryrun

$ afasi translate minimal-in.xml --table minimal.json --dryrun
dryrun requested
# ---
* resources used:
  - input from:       "minimal-in.xml"
  - output to:        STDOUT
  - translation from: "minimal.json"
* translations (in order):
  1. '>Rock' -> '>Lounge'
  2. '>Track' -> '>Rock'
* diff of source to target:
--- SOURCE
+++ TARGET
@@ -6,12 +6,12 @@
         <message id="SOME_TRACK">
             <source>Some Track</source>
             <extracomment>Does not matter.</extracomment>
-            <translation>Track</translation>
+            <translation>Rock</translation>
         </message>
         <message id="SOME_ROCK">
             <source>Some Rock</source>
             <extracomment>Does not matter.</extracomment>
-            <translation>Rock</translation>
+            <translation>Lounge</translation>
         </message>
     </context>
 </TS>
# ---

Translate

$ afasi translate --input minimal-in.xml --output minimal-out.xml --table minimal.json
$ afasi % diff -u minimal-*.xml
--- minimal-in.xml  2021-10-20 20:12:54.000000000 +0200
+++ minimal-out.xml 2021-10-20 20:14:45.000000000 +0200
@@ -6,12 +6,12 @@
         <message id="SOME_TRACK">
             <source>Some Track</source>
             <extracomment>Does not matter.</extracomment>
-            <translation>Track</translation>
+            <translation>Rock</translation>
         </message>
         <message id="SOME_ROCK">
             <source>Some Rock</source>
             <extracomment>Does not matter.</extracomment>
-            <translation>Rock</translation>
+            <translation>Lounge</translation>
         </message>
     </context>
 </TS>

Example Translation Tables

Simple version (parallel arrays):

[
  [">Rock", ">Lounge"],
  [">Track", ">Rock"]
]

Augmented version (object):

{
  "table": {
    "description": "table level default constraints, row attributes do replace those if present.",
    "contra": [
      "extracomment",
      "source"
    ],
    "count": 0,
    "flip_is_stop": true,
    "flip_flop": [
      "<message id=\"SOME_TRACK\">",
      "</message>"
    ],
    "pro": [
      "translation"
    ]
  },
  "foo": "bar",
  "translations": [
    {
      "repl": ">Lock",
      "ace": ">Launch"
    },
    {
      "repl": ">Track",
      "ace": ">Lock"
    },
    {
      "repl": ">Autotrack",
      "ace": ">Autolock"
    },
    {
      "repl": "lock r",
      "ace": "launch r"
    },
    {
      "repl": "track r",
      "ace": "lock r"
    }
  ]
}

Command Line API

  • afasi
    • afasi template
    • afasi translate
    • afasi version

afasi

Fuzz a language by mixing up only few words.

The translation table entries are applied in order per line of input. So, with large translation tables the performance will obviously degrade with a power of two. The latter should be taken as a hint to maintain both language files in separate entities not as a patch task.

The translation table is either an array of two element arrays provided as JSON and thus shall be in a shape like:

  [
    ["repl", "ace"],
    ["als", "othis"]
  ]

Or the table is given as an object providing more detailed instructions constraining the translation rules like:

  • contra indicators - when given exempting a line from translation
  • pro indicators - when given marking a line for translation
  • flip_flop indicators - providing either stop-start (default) or start-stop state switching

The JSON object format is best understood when executing the template command and adapting the resulting JSON object written to standard out.

Default for input source is standard in and out per default is sent to standard out.

Usage:

$ afasi [OPTIONS] COMMAND [ARGS]...

Options:

  • -V, --version: Display the afasi version and exit [default: False]
  • -h, --help: Show this message and exit.

Commands:

  • template: Write a template of a translation table JSON...
  • translate: Translate from a language to a 'langauge'.
  • version: Display the afasi version and exit

afasi template

Write a template of a translation table JSON structure to standard out and exit

Usage:

$ afasi template [OPTIONS]

Options:

  • -h, --help: Show this message and exit.

afasi translate

Translate from a language to a 'langauge'.

Usage:

$ afasi translate [OPTIONS] [SOURCE] [TARGET]

Arguments:

  • [SOURCE]: [default: STDIN]
  • [TARGET]: [default: STDOUT]

Options:

  • -i, --input <sourcepath>: Path to input file (default is reading from standard in) [default: ]
  • -o, --output <targetpath>: Path to non-existing output file (default is writing to standard out) [default: ]
  • -t, --table <translation table path>: Path to translation table file in JSON format. Structure of table data is [["repl", "ace"], ["als", "othis"]] [default: ]
  • -n, --dryrun: Flag to execute without writing the translation but a diff instead (default is False) [default: False]
  • -h, --help: Show this message and exit.

afasi version

Display the afasi version and exit

Usage:

$ afasi version [OPTIONS]

Options:

  • -h, --help: Show this message and exit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afasi-2021.10.22.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

afasi-2021.10.22-py2.py3-none-any.whl (14.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file afasi-2021.10.22.tar.gz.

File metadata

  • Download URL: afasi-2021.10.22.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for afasi-2021.10.22.tar.gz
Algorithm Hash digest
SHA256 7e31edbbfcfb0cd02948830dd82aef9c274935aeb80de121679a1af1c481a3c5
MD5 6dbf5fc2da3c68e277976e754a02e6d1
BLAKE2b-256 a7036830b133659bff2e05c3a02a34d1995cf8c11aa2fe4a3c864f39fdb359b2

See more details on using hashes here.

File details

Details for the file afasi-2021.10.22-py2.py3-none-any.whl.

File metadata

  • Download URL: afasi-2021.10.22-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for afasi-2021.10.22-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8582f77df83c05b3c729518e36035a8dd58112e0e281b5003bbf8d10853de964
MD5 8bb93355f61db41f76cd425822701644
BLAKE2b-256 98a0989f10ea016b600a75e27768b28b4b0370da3c61a6c4d729f2cd20a15b5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page