Mario Kart's just another word for...

Posted by Dillon Reedy on 2017-06-30

‘Go Kart ‘

I need to get out of the puns market.

Hey guys! How have you been? Yeah, me too. Shouldn’t have gone to the bars that night. Writer’s block has taken a toll on me, that’s why I haven’t contributed in 3 months.
Anyways, enough chit chat. GO mfer! How do you like it? From what I’ve heard, it’s just syntactic sugar over the C language or “idk anything about GO!”. Well if you’re the latter then this project is for you. It’s a very simple intro into the work.


You’re gonna need a text editor (Sublime, Brackets, etc.) for your work on this project. You’re also going to need to download the binary release from the Go website. The installer is pretty straightforward, and easy to use. Get your books you want to mine from, from any website, but I personally used this. Create a Main.go file in your text editor and you’re basically ready to Go (pun intended)!

Problem Description

So for the SATs they typically will ask you a synonym question, for example:

Name the closest synonym to “feline”:

  1. Cat
  2. Dog
  3. Cow
  4. Horse

Now how could you solve this problem without a thesaurus and only a Go program and all the Harry Potter books?

Well we’re gonna do that through semantic similarity. The semantic similarity of two words is a measure of the closeness between their meanings. We’re going to calculate the given word and a given synonyms’ likelihood of being synonyms. You can get a much more full description of the problem we are solving here

Go Pros and Cons

Pro - It’s very easy to import custom packages once you get ahold of it. Prior projects it has not been as easy. To import a package, I placed my Go file into a separate folder within the project, built the file, and then copied that whole project into C:\Go...\src and C:\Go...\pkg folders. In my main Go file, I import by package name.
Pro - I like the implementation of the “Don’t Care” value when receiving values back from a method call. I haven’t been exposed to that outside of a functional programming language, so it’s a breath of fresh air to be seeing something new.
Con - I considered this more of a inconvenience than an actual “Con”, but having to name my exported functions camel case style, to be able to use them outside of the package, was just one of those annoying things to have to go back and change, but I do like how it forces the programmer to stick to a specific style.
Con - Implementation of a for-each loop, I’d like to see that made simpler, but I understand why they’ve made it so terse to use.

Analysis of my Go Solution to the SAT Problem

Before we get started, I tried dividing my code into logical sections: “Gather Input”, “Sanitize Input”, “Similarity Calculator”, and “Data Creator”. I felt that by doing this we have more coherent and understandable code. So far out of all the languages I’ve reviewed, Go has been the easiest to import another class upon once you learn how to do it.
The solution we end up implementing gathers all the sentences of the books, and for any word within the sentence, for another word within the sentence, these two words gain a point. We end up storing a jagged dictionary of dictionaries for our solution. The math formula we then end up using is the cosine formula.

Main Section

In the Main section, I try to my input code from my logic code. It really helps a programmer out when you’re able to separate code very logically. I’d like to highlight one line of code here, that I really like about Go. We receive two results when we input a key into a map.

_, ok := lexiconMap[word]
if (ok) {

The first I set to a don’t care value, but the 2nd is “ok” which is set

Data Creator File

Within Data Creator, the hardest method I had to come about implementing was the CreateSentences method.

func CreateSentences(book string) ([]string) {
var pSentences []string = strings.Split(book, ".")
var pqSentences []string
for v := range pSentences {
var pqChunkSentences []string = strings.Split(pSentences[v], "?")
for q := range pqChunkSentences {
pqSentences = append(pqSentences, pqChunkSentences[q])
var pqeSentences []string
for v := range pqSentences {
var pqeChunkSentences []string = strings.Split(pqSentences[v], "!")
for q := range pqeChunkSentences {
pqeSentences = append(pqeSentences, pqeChunkSentences[q])
return pqeSentences

Luckily I came up with an an interesting solution to where I split the entire text upon its’ periods. Then upon those chunks I split upon the question marks, and then upon those chunks I split upon the exclamation points. This is all very straightforward thinking at the end, but creating this at the beginning was not very straightforward.

Grading the Go Language

If I had to choose between getting introduced to Go or C, I’d definitely take Go. When executing my program, it reads in all 7 Harry Potter novels reasonably fast. So that is a major plus about this language. To further work on this project, we might implement a UI, and also use different ways to calculate out a score. I’d give this language an A-.