Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Omega/tests/FileScoreReference.swift # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Omega / tests / FileScoreReference.swift` 18 lines ยท 667 bytes Raw Blame History 1 import Foundation 2 3 /// The Swift path scoring Hop shipped up to 0.4.0, kept only as the reference the Omega core is checked against. 4 enum FileScoreReference { 5 static func score(path: String, terms: [String]) -> Int? { 6 let lowPath = path.lowercased() 7 let name = (lowPath as NSString).lastPathComponent 8 var s = 0 9 for t in terms { 10 if name.contains(t) { s += name.hasPrefix(t) ? 60 : 30 } 11 else if lowPath.contains(t) { s += 5 } 12 else { return nil } 13 } 14 s -= path.utf8.count / 20 15 if name.utf8.count == terms.reduce(0, { $0 + $1.utf8.count }) { s += 40 } 16 return s 17 } 18 }