forked from torifat/iAvro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutoCorrect.swift
More file actions
31 lines (25 loc) · 807 Bytes
/
AutoCorrect.swift
File metadata and controls
31 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// AutoCorrect.swift
// AvroKeyboard
//
// Created by Mamnun Bhuiyan on 26/4/17.
//
//
import Foundation
@objc public class AutoCorrect: NSObject {
var entries: [String: String] = [:]
static let shared: AutoCorrect = AutoCorrect()
override init() {
super.init()
guard let filePath = Bundle.main.path(forResource: "autodict", ofType: "plist") else { return }
if FileManager.default.fileExists(atPath: filePath) {
if let dict = NSDictionary(contentsOfFile: filePath) as? [String:String] {
entries = dict
}
}
}
public func find(_ term:String) -> String? {
guard let fixedTerm = AvroParser.sharedInstance().fix(term) else { return nil }
return entries[fixedTerm]
}
}