-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert JSON data to SQLite #96
Comments
Is not reproducible on an iPhone 7 in Simulator, but then the version is 15.2. Other translation features work fine, so shouldn't be an issue with accessing the data as the size is relatively similar (although Russian has the largest translation file by 0.6MB). |
I may take a look on this issue |
This would be absolutely amazing! 🚀🚀 I really haven't had the bandwidth to dedicate time to this, but it's the main bug right now that dramatically affects the functionality. Let me know if you have ideas on this! |
Yep, assign me on this please and I'll let you know on my progress with this issue |
Assigned! Thank you 😊 |
@japanese-goblinn, reporting that apparently v2.0 Made this even worse, as basically the Russian keyboard crashes from the start at this point 🤦♂️ This is not happening on the emulator, and sadly we don’t have device level testing happening at this point. The crashes that other keyboards were experiencing have actually gotten better. I’m wondering if this is maybe an issue with the amount of data that Russian’s ingesting? All the other keyboards have similar amounts of data, but Russian has those almost 200k bound. Could be crashing because it can’t handle it? |
@andrewtavis I've looked intro this crash and will soon describe here what I've found |
Thanks so much, @japanese-goblinn! Really looking forward to what you’ve figured out :) |
@japanese-goblinn, note that I just checked and the new "lack of" behavior is reproducible sometimes on the Simulator, I just didn't check Russian after all these changes. Am looking into this as well now :) |
Well, I managed to get this error while debugging, but not really sure how to reproduce it (screenshots below). I want to take a deeper look into this bug but unfortunately I don't have time for now. This is what I found so far: You sad that file is about // func loadJSONToDict
let data = try Data(contentsOf: url)
let f = ByteCountFormatter()
f.allowedUnits = [.useMB]
f.countStyle = .memory
print("[DEBUG]: file \(fileName) size \(f.string(fromByteCount: Int64(data.count)))") It's not much but it's a measurement of raw data, so it's less that I also tried to use profiler but that was not really helpful, it's only showed that a really slow disc read is happening but you can see it yourself - keyboard is taking 2-3 seconds to startup (at least in dev mode). As a conclusion I'm not sure if slow app startup is causing sometimes to crash, because you can't be absolutely sure if system will kill your application due to slow start. What I'm absolutely sure about is that you need to rework your data structures and whole approach of working with data (read only batches not whole file, using DB, etc.) and I can sure your that application will become event better and hopefully you'll manage to fix this bug! I hope you luck in this hard task and thank you for possibility to contribute! |
@japanese-goblinn, wanted to thank you for your contributions! #231 is an initial step towards working on this in my opinion, as we really should be leveraging a library for JSON loading. Hopefully this will make the read only batches you suggested or another solution for the data process easier going forward 😊 All the best, and your contributions are welcome whenever you have time! :) |
#96 add SwiftyJSON for data and refactor code
We'll likely need to be using Core Data for this in the future, but a WIP step to help the situation would be to remove the indentation from all JSON files to make them smaller in size. |
@SaurabhJamadagni, FYI for this issue, I have the JSON files formatted to remove spaces, which really does help as far as app size is concerned. Will push those with the QWERTY French keyboard for #229 :) It sadly doesn’t seem to help to much with load times, as it’s likely the crazy number of lookups being done that’s problematic. I’m going to a Berlin Swift coding group on Thursday and will discuss with people how best to implement Core Data or another solution that will help us now directly load all these dictionaries into memory all at once 😊 |
Hey! 👋
Yeah, I'm thinking this could wait until we're able to do cross-translations - in whatever way this is accomplished in scribe-org/Scribe-Data#23. I was more so pointing out perhaps that the current
This is what I want to make sure to think through. I think there will be three steps that are more time-heavy or resource-heavy that happen when a data download is done:
For these steps, the file format should facilitate an efficient download workflow. FWIW I am currently thinking
I guess the reservation that I'm having is more so coming from putting myself in the perspective of a user of Scribe-Data (as a general-use package). Like, would I care enough about the Maybe it's fine actually. I'm not definitely opposed. I'm perhaps more trying to think from the mindset that, as a user of packages, I would like my packages to do what I need them to, be small and compact, and have a clear use/purpose - if that makes sense.
I'm with you! 👍 |
I'm definitely of the opinion that as soon as more options are available for translation that instead of Glad to hear that it sounds like
I think it also depends on who the people are that first want to use it for non-Scribe purposes, but definitely happy to remove the bloat and even have a lot of the multi-use stuff be in Server for a wider community where Scribe-Data is more just what we need :)
🚀🚀🚀😊 |
Very simple question as well, @wkyoshida and also @SaurabhJamadagni: does my idea of versioning for all this make sense? Scribe-iOS is going to v2.2.0 as what the user is experiencing is just some new features like the emoji suggestions, etc — i.e. nothing "breaking" per say. The functionality of Scribe-Data is being totally changed though to export something different with tons of breaking changes, hence that's going to v3.0.0. |
Oki doki 😊 Soooo, querying database values 😉😉😉 Here are the functions I'm making and a simple example: import GRDB
// get_iso_code is new and returns the two letter code for the language (ex: Deutsch -> de)
/// Makes a connection to the language database given the value for controllerLanguage.
func openDBQueue() -> DatabaseQueue {
let dbName = "\(String(describing: get_iso_code(keyboardLanguage: controllerLanguage).uppercased()))LanguageData"
let dbPath = Bundle.main.path(forResource: dbName, ofType: "sqlite")! // ex: dbName = DELanguageData
let db = try! DatabaseQueue(
path: dbPath
)
return db
}
/// Returns a value from the language database given a query and arguemtns.
///
/// - Parameters
/// - query: the query to run against the language database.
/// - args: arguments to pass to the query.
/// - outputCols: the columns from which the value should come.
func queryDB(query: String, args: [String], outputCols: [String]) -> [String] {
var outputValues = [String]()
do {
try languageDB.read { db in
if let row = try Row.fetchOne(db, sql: query, arguments: StatementArguments(args)) {
for col in outputCols {
outputValues.append(row[col])
}
}
}
} catch {}
return outputValues
}
var languageDB = try! DatabaseQueue() // instantiated for assignment within CommandVariables.swift
languageDB = openDBQueue() // on firstKeyboardLoad == true within loadKeys()
// Example in another file:
let query = "SELECT * FROM emoji_keywords WHERE word = ?"
let args = ["gesicht"]
let outputCols = ["emoji_1"]
spaceBar = queryDB(query: query, args: args, outputCols: outputCols)[0] Which then gives us 🥁🥁🥁🥁: Will do a PR soonish with the above a bit more organized 😊 |
I think that this is a good way of going about this, but feedback would be welcome :) Specifically we'll need to keep track of the index of certain columns passed within |
Progress so far for me locally: all commands have been switched over 😊 So I'm going to work on switching over autosuggestions right now. A note is that the way we do autocompletions is the thing that will need to make the biggest shift, and will likely need a custom query (totally fine that it would 🙃). We need to get rid of the |
Hey @andrewtavis! Yeah that makes sense. With all the internal changes going on, Scribe-iOS version also seems like a big jump to me but I can see how the numbering would make sense from a user's perspective. Sounds great 😊 |
Remaining issues after the commit I'm about to do 😊
|
Alrighty then! 3be5a59 is massive 😱😊 It also includes two bug fixes that can be seen in the commit logs for the What we've all been waiting for 🙃:
I've been doing lots of testing and it all seems to be working great so far aside from one issue: for some reason I can't get it so that lower case versions of German nouns (that are capitalized) are not in the autocomplete lexicon... This was a problem a long time ago when we first added autocomplete/autosuggest. What I means by this is that there are two versions of most German nouns: Most important thing: I really think that this has worked 😊😊😊 We'll see, but before doing all this there was some serious lag still while using the Russian keyboard. In the initial tests since the changes it seems to be very responsive 🔥🚀🔥➡️🌔😅 If someone has suggestions for the nouns I'd be grateful! Glad this is coming to a close 😊 |
The above is the function for the autocomplete creation. Just to list it, this is the logic that I'm trying to put into the autocomplete lexicon:
We could also edit the drop duplicates function that's called after the UILexicon words (names from Contacts that are unordered) are added:
|
An idea after a night’s sleep 😴💡: a self join to remove the lower case versions of capitalized/upper case words might make sense. |
This has been fixed at this point :) Hyphenated words have been removed, and I'm actually keeping numbers as I think they help match the emoji suggestions for 10 on a clock, etc. We're selecting words that are longer than two characters for everything except emojis for this purpose. We can change it later based on live testing 🙃 |
d9e3cb0 solution wasn't what we wanted, but 91b4791 fixes it :) As expected it was something pretty standard. Now what's happening in the selection step of the autocomplete lexicon query is we're joining on the |
Thanks all for your support and ideas on all this! Major milestone for Scribe finished 😊 Here's hoping it'll work once we get it onto devices 🤞 |
Hey @andrewtavis, sorry coming to this a bit late. I wish there was a way to star an issue because I am pretty sure I am going to be coming back here a lot. Loving the process documentation. I hate I was no help but thank you so much for all the changes! This is going to be awesome!! 🚀 |
There’s a little bit left for this to be pushed later on today, @SaurabhJamadagni, but I’ll send it along soon. There’s so much new data (as mentioned on Matrix 😉) that I actually needed to do further optimizations to what we had before 😊 Will send it along with #284 later :) |
A final note on this issue is that the Russian keyboard's translation feature — the original issue that lead to all this — is now functional in v2.2.0 on device 😊😊 |
Terms
Behavior
There’s currently a bug with v1.1.0 where the Russian keyboard will not translate words. The keyboard switches to English as it should, and words can be typed, but then on pressing return the keyboard crashes without anything being inserted.
Device type
iPhone 7
iOS version
iOS 15.1
The text was updated successfully, but these errors were encountered: