A Better way to convert Words?

I have a need to read various files, and convert some of the words to a specific case (which can’t be done using normal functions like upper, lower or title)
Right now I have a rather large method that inserts keys into an SQLite database

The app the ultimatly needs to deal with these files is very strict on case

CREATE TABLE translate ( 
KEY Text COLLATE NOCASE UNIQUE DEFAULT '',
newVALUE Text COLLATE NOCASE DEFAULT '')

this is done with 3 different methods


private func addKey_UPPER(_ newValue: String) {
	let key=newValue.uppercased()
	storeAs(key,newValue)
}

private func addKey_DELETE(_ newValue: String) {
	let key=newValue.uppercased()
	storeAs(key,"*")
}

private func addKey_REPLACE(_ key : String, _ newValue: String) {
	storeAs(key.uppercased(),newValue)
}

private func storeAs(_ key:String,_ newValue:String) {
	let _ = DB.SQLExecute("INSERT INTO \(translateTABLE) (key,newValue) VALUES('\(key)','\(newValue)')")
}

at the appropriate time a word is looked up in that table by KEY and replaced by its “NEWVALUE”. or removed if newvalue="*"

anyone have an idea how to create this table with cleaner code?
right now there are 559 “words” in this table, and I expect the need to increase

so they really just need to be consistently cased ?

the list does one of 3 things

  • takes a word and returns a properly cased version
  • takes a word and replaces it with another (ie. “Opening” becomes “Open”) :slight_smile:
  • marks the word as unnecessary and removes it (ie. “NEW”)

right now the contents of the SQLite table (seeded when the app starts)

  • “SHOWPROGRESS”,“showProgress”
  • “OPENING”,“open”
  • “NEW”,"*"

Right
So why couldnt it just return the new replacement alway upper, lower, title cased ?
At least it would be consistent which is all other tool needs. No ?