Created
October 29, 2017 13:53
-
-
Save darcwader/1005b167e1b0c0f9596d176ea90d6d9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init() { | |
| let wordsPath = Bundle.main.url(forResource:"words_array", withExtension:"json") | |
| do { | |
| let wordsData = try Data(contentsOf: wordsPath!) | |
| if let wordsDict = try JSONSerialization.jsonObject(with: wordsData, options: []) as? [String:Int] { | |
| self.vocabulary = wordsDict | |
| } | |
| } catch { | |
| fatalError("oops could not load words_array") | |
| } | |
| let idfPath = Bundle.main.url(forResource: "words_idf", withExtension: "json") | |
| do { | |
| let idfData = try Data(contentsOf: idfPath!) | |
| if let idfJson = try JSONSerialization.jsonObject(with: idfData, options: []) as? [String:[Double]] { | |
| self.idf = idfJson["idf"]! | |
| } | |
| } catch { | |
| fatalError("oops could not load words_idf file") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment