Skip to content

About

Native macOS file classifier: FSEvents watching, Vision OCR, PDFKit and NaturalLanguage sentence embeddings, all on device (SwiftUI, SwiftData)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

CipherSort (macOS)

A SwiftUI app that watches a folder and works out what each new file is (a receipt, a tax form, lecture notes, a résumé, a screenshot) using only Apple's on-device frameworks. Nothing is uploaded anywhere: text comes from Vision OCR and PDFKit, meaning comes from NaturalLanguage sentence embeddings, and the watching is done with FSEvents.

This is the native rewrite of cyphersort, the Python + Ollama version that also files results into a Cryptomator vault.

How a file gets a category

  1. Watch. An FSEventStream with file-level events reports every file created in the chosen folder. You can also drag files onto the window or pick them.
  2. Read. OCR (VNRecognizeTextRequest, accurate mode with language correction) and PDF text extraction run concurrently with async let. Each one also reports a text-quality score.
  3. Embed and compare. The extracted text plus filename and metadata keywords goes through NLEmbedding.sentenceEmbedding(for: .english) and is compared against a short prototype description of each category (Finance/Receipts, Finance/Taxes, School/LectureNotes, Career/Resume, Career/Offers, Development/Projects, Development/InterviewPrep, Screenshots, Documents/*). If the embedding model isn't available, a weighted keyword table takes over.
  4. Blend with metadata. Metadata scores and embedding scores are mixed, and the weight shifts with text quality: a clean PDF trusts the text (up to 75%), a blurry screenshot leans on metadata. A few targeted rules handle the classic confusions. Documents that look like receipts or tax forms can override the blend, while ads full of prices get pushed back toward Documents/General.
  5. Report honestly. Confidence is clamped to 35-96%, and to at most 65% when the call rests on metadata alone, so the UI never presents a guess as certain.

Learned rules (filename pattern → category, with a minimum confidence and a success count) and a history of every decision are stored with SwiftData.

Benchmarks

Run Tests in the app runs two suites and prints the results to the console:

  • A synthetic set of labeled examples, reporting accuracy and average confidence.
  • A sample of up to 20 files per class from the RVL-CDIP document dataset (invoice → receipts, resume → résumé, letter → general, and so on), run through the full pipeline including OCR. Point the app at a local copy of the dataset; it isn't included in the repo.

Build

Open CipherSort.xcodeproj in Xcode (macOS 14+, Swift 5.9+) and run. The app is sandboxed and asks for folder access through the standard picker.

Layout

Path Role
Watcher/FilesystemWatcher.swift FSEvents stream
Analysis/OCRAnalyzer.swift, PDFAnalyzer.swift Text extraction plus quality scores
Analysis/MetadataAnalyzer.swift Filename, extension and type signals
Analysis/NLPClassifier.swift Sentence-embedding classifier with keyword fallback
Categorization/CategorizationManager.swift Score blending, overrides, confidence caps
Persistence/RuleStore.swift SwiftData rules and history
App/ SwiftUI window, drag and drop, benchmark runners

About

Native macOS file classifier: FSEvents watching, Vision OCR, PDFKit and NaturalLanguage sentence embeddings, all on device (SwiftUI, SwiftData)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages