<commit_before>property thumbSize : 480

on getImages(f)
  tell application "Finder" to return (files of folder f) as alias list
end getImages

on run argv
  set keynotePresentation to item 1 of argv
  set tmpKeynotePresentation to item 2 of argv

  set keynotePresentation to (POSIX file keynotePresentation) as alias
  set tmpkeynotePresentation to (POSIX file keynotePresentation) as alias

  tell application "Keynote"
    activate
    open tmpkeynotePresentation

    if playing is true then stop the front document
    set documentName to the name of the front document
    if documentName ends with ".key" then set documentName to text 1 thru -5 of documentName

    tell application "Finder"
      set keynoteContainer to (container of keynotePresentation) as alias
      if not (exists folder documentName of folder keynoteContainer)
        make new folder at keynoteContainer with properties {name:documentName}
      end if
      set the targetFolder to folder documentName of folder keynoteContainer
      set the targetFolderHFSPath to targetFolder as string
    end tell

    export front document as slide images to file targetFolderHFSPath with properties {image format: JPEG}
    set jpegs to my getImages(targetFolderHFSPath)
    repeat with thisJPEG in jpegs
      try
        tell application "Image Events"
          launch
          set this_image to open thisJPEG
          scale this_image to size thumbSize
          save this_image with icon
          close this_image
        end tell
        on error error_message
          display dialog error_message
      end try
    end repeat

    close front document without saving
  end tell
  return POSIX path of keynoteContainer
end run<commit_msg>update applescript to work with a filter<commit_after>-- thumbscrew.scpt
-- usage: thumbscript.scpt <path_to_root_dir> <path_to_keynotePresentation> <presentation_name>
--
-- Will create scaled thumbnails of length `thumbSize` in the directory
-- <path_to_root_dir>/.keynote/<presentation>
property thumbSize : 480
property thumbnailDir: "keynotes"

on getImages(f)
  tell application "Finder" to return (files of folder f) as alias list
end getImages

on run argv
  set gitRoot to item 1 of argv
  set tmpFile to item 2 of argv
  set documentName to item 3 of argv
  if documentName ends with ".key" then set documentName to text 1 thru -5 of documentName

  set gitRoot to posix file (POSIX path of (gitRoot as text) & "/" & thumbnailDir) as alias
  set tmpFile to (POSIX file tmpFile) as alias

  tell application "Keynote"
    activate
    open tmpFile

    if playing is true then stop the front document

    tell application "Finder"
      if not (exists folder documentName of folder gitRoot)
        make new folder at gitRoot with properties {name:documentName}
      end if
      set the targetFolder to folder documentName of folder gitRoot
      set the targetFolderHFSPath to targetFolder as string
    end tell

    export front document as slide images to file targetFolderHFSPath with properties {image format: JPEG}
    set jpegs to my getImages(targetFolderHFSPath)
    repeat with thisJPEG in jpegs
      try
        tell application "Image Events"
          launch
          set this_image to open thisJPEG
          scale this_image to size thumbSize
          save this_image with icon
          close this_image
        end tell
        on error error_message
          display dialog error_message
      end try
    end repeat

    close front document without saving
  end tell
  return POSIX path of gitRoot
end run
{'fraction_non_alphanumeric': 0.0302945301542777, 'fraction_numerical': 0.004207573632538569, 'mean_word_length': 3.084765177548683, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2590375', 'n_tokens_mistral': 968, 'n_tokens_neox': 917, 'n_words': 442}