As noted before the dictionaries on macOS 10.15 are located in /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX
.
A list of installed dictionaries could look like this:
$ gfind /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX -type d -name '*.dictionary' -printf '%f\n'
New Oxford American Dictionary.dictionary
Duden Dictionary Data Set I.dictionary
Apple Dictionary.dictionary
Oxford Dictionary of English.dictionary
German - English.dictionary
Oxford American Writer's Thesaurus.dictionary
Oxford Thesaurus of English.dictionary
reverse_data.py
from parse_dictionaries
can be used to extract individual entries from dictionaries1.
$ python reverse_data.py --lookup berth
Parsing /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/4094df88727a054b658681dfb74f23702d3c985e.asset/AssetData/New Oxford American Dictionary.dictionary/Contents/Resources/Body.data...
(...)
98.9% // 102991 entries parsed // Latest entry: mark
fbm_AdvisoryBoard detected, stopping...
Augmenting...
Getting links...
Getting links: 99.6%Links: 24263
Saved 1 definitions at lookup/lookup.html.
A rendering of lookup/lookup.html
in Safari.
There is an accompanying blog posting describing the technical background.
apple-dictionary
can be used to extract an entire dictionary.
Extract the XML of the New Oxford American Dictionary as described in the manual.
$ ./dedict "/System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/4094df88727a054b658681dfb74f23702d3c985e.asset/AssetData/New Oxford American Dictionary.dictionary/Contents/Resources/Body.data" | ./strip | ./checkxml.py > dictionary.xml
Convert the XML to a sqlite database.
$ ./appledict2sqlite3.py < dictionary.xml
Perform a sample query on the database and filter the definitions.
$ sqlite3 dictionary.db "select entry from definitions where title='berth';" | tidy -quiet --input-xml yes -wrap 0 | grep def=
<span d:def="1" role="text" class="df">a ship's allotted place at a wharf or dock
<span d:def="1" role="text" class="df">a fixed bed or bunk on a ship, train, or other means of transport
<span d:def="1" role="text" class="df">(often in a sports context) a situation or position in an organization or event
<span d:def="2" role="text" class="df">moor (a ship) in its allotted place
<span d:def="2" role="text" class="df">(of a passenger ship) provide a sleeping place for (someone)
1. By default the New Oxford American Dictionary is used for lookups. Other dictionaries may or may not work, e.g. the lookup in the Oxford Dictionary of English didn't complete when I looked up a word.