Skip to content

Add CLI method 'map-symbols-in-pronunciations-json' #1

@stefantaubert

Description

@stefantaubert

A new method named map-symbols-in-pronunciations-json is needed which should work exactly as map-symbols-in-pronunciations but the symbol mappings are loaded from a json file.

Example json for mapping the two ARPAbet symbols AO and EY to their IPA representation:

{
  "AO": "ɔ",
  "AO0": "ɔ",
  "AO1": "ˈɔ",
  "AO2": "ˌɔ",
  "EY": "",
  "EY0": "",
  "EY1": "ˈeɪ",
  "EY2": "ˌeɪ",
}

Note: The order of the mappings inside the json file should be irrelevant! This means for example if the option --partial-mapping is set, that putting the mapping "AO": "ɔ" before "AO1": "ˈɔ" would not result in all AO1 to be mapped to ɔ1. Instead they should be mapped to ˈɔ. To handle this issue, my suggestion is to map the symbols descendant according to their character count, i.e., first map all with three characters (AO0, AO1, ...) and then map all with two characters (A0 and EY).

Example usage:

# Create example dictionary
cat > "/tmp/example.dict" << EOF
test  AO AO2 AA1 EY2 .
EOF

# Map with the example json written to /tmp/mapping.json from above
dict-cli map-symbols-in-pronunciations-json \
  "/tmp/example.dict" \
  "/tmp/mapping.json"

The content of /tmp/example.dict should then be:

test  ɔ ˌɔ AA1 ˌeɪ .

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions