I’m not sure if “Keyword finder” is the right word for this, so I will try to explain it best I can. I need an easy keyword searcher thing that will take a string and find keywords associated with the word (If it is a word obviously). An example might be the string “Bacon” would bring up keywords like “Food” or “Meat” and put them in an array or something (That’s just an example and not what I want this keyword associator for by the way). I am just wondering if anyone has a function written in Swift somewhere on the internet that will do this. Thanks in advance. Any help is appreciated.
Keyword finder in Swift
Do you intend to build the link between bacon and Food and Meat by yourself or do you intend to get it done automatically or progressively building the links over use of the app ?
In that case, you could:
1. Build an array of keywords and populate it:
var keywords : [String] = ["Food", "Meat"]
you will extend this array dynamically later.
2. Create a dictionary association: [String : [String]] to associate an array of keywords to an item as "bacon" (you have to take care of upper / lowercase)
each time you discover a new association, you'll write :
if association["bacon"] == nil {
association["bacon"] = []
}
association["bacon"].append(forKeyword)
This should be in a func
func buildAssociation(word: String, forKeyword: String) {
if association[word] == nil {
association[word] = []
}
association[word].append(forKeyword)
}This discovery could be done by presenting user with the list of keywords.
if you create a new keyword, you'll have to add to keywords array.
That is a great way to do it that I never thought of, thanks. I will use that if I can't find anything else, but I was wondering if there was some code that already has the keywords attached to the words and stuff so that I wouldn't have to program it myself.
Looks like the keywords will be yours. There is no universal classification available AFAIK.
How detailed is your keywords dictionary ? 10 items ? 100 ? 10 000 ?
What domain do you want to cover : specific (as food) ? General : engineering, All english vocabulary ?
This just illustrates that this disctionary will be specific to your app.
And programming will be straightforward.
What would be good in your app is to let user create new keywords. Of course you'll have to save it on file to be kept when you relaunch app.
I really want the entire english dictionary in my app but I'm not sure if that would really be possible.
Even before loading the disctionary (if you find one which is copyright free), a key question is "how to build the keywords".
Are you already clear on the type of keywords ? This taxonomy is probably something that you must decide on by yourself, because it depends on what your app will be.
There are a lot of references about taxonomies (search Google with english vocabulary existing taxonomy); here is a link that may help you in your search of existing taxonomy or thesaurus:
h ttps://books.google.fr/books?id=yTKNBQAAQBAJ&pg=PA52&lpg=PA52&dq=english+vocabulary+existing+taxonomy&source=bl&ots=_ZNYOuhu_0&sig=srEzbuERt4zRdkQ6APcMxOIO61M&hl=fr&sa=X&ved=0ahUKEwilxIvfoojVAhWFVRoKHVUwCtoQ6AEIXDAH#v=onepage&q=english%20vocabulary%20existing%20taxonomy&f=false