Optimize the wikidatatype separation a little with --first-match-only.  Ordering the patterns by descending expected frequency would help further.
"source": [
"!$kgtk filter --verbose=$VERBOSE",
" --use-mgzip $USE_MGZIP",
+ " --first-match-only",
" --obj 'node2;wikidatatype'",
" -i $WIKIDATA_PARTS/part.claims.$SORTED_EXTENSION",
" -p ';; commonsMedia' -o $WIKIDATA_PARTS/part.commonsMedia.$SORTED_EXTENSION",
"source": [
"!$kgtk filter --verbose=$VERBOSE",
" --use-mgzip $USE_MGZIP",
+ " --first-match-only",
" --obj 'node2;wikidatatype'",
" -i $WIKIDATA_PARTS/part.property.$SORTED_EXTENSION",
" -p ';; commonsMedia' -o $TEMP/part.property.commonsMedia.$UNSORTED_EXTENSION",
