6

I’m studying the Dutch language, and the built-in dictionary has plenty of example sentences that are superior to the ones in the materials I’ve been working with from Loecsen.  I'd like to put many of them (a few at a time) into Anki for memory drill.

But Apple has disabled copy on the pop-up. Perhaps that’s a copyright issue, in which case my question is irrelevant. But if not, I’d like some way to get to them other than screen shot, OCR, and cleanup.

The same dictionary is also on my iPad, so a way to access that would be useful as well.

I understand they are XML, which would mean they shouldn't be hard to parse, but I haven't found anything like that so far.

Update: I’m still interested in the answer, but I found a source that’s better for my purposes.

2
  • Bit of an X-Y question, as you really seem to be looking for a way to copy items from the OS dictionaries, rather than wanting to know the files' location. The dictionaries are NOT in a human-readable format.
    – benwiggy
    Commented Oct 16, 2020 at 11:41
  • Indeed. But there are open-source projects converting to and from that format, so it must be documented somewhere. I left the question up in case anyone else wants to know the location.
    – WGroleau
    Commented Oct 16, 2020 at 16:41

3 Answers 3

3

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.

dictionary definition of berth

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.

4
2

"I’d like some way to get to them other than screen shot, OCR, and cleanup."

MacOS comes with a Dictionary.app which uses the same resources as the Lookup pop-up. You can copy text from there.

enter image description here

You can choose which dictionaries are included in the app's Preferences.

The Apple .dictionary format is not XML and is not human-readable without some decoding.

1

Apparently the location for 10.15.7 is /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/*.asset/AssetData/Dutch - English.dictionary where "*" is a long GUID.

But I can't find a description of the format. Some web pages say it's XML, but that does not appear to be the case.

1
  • 1
    This is not correct for all versions of macOS. Please include version info… Commented Oct 16, 2020 at 10:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .