'Build representation of query, e.g. words or n-grams'

def build_query_representation(self, query):

    rep = {}
    rep['words'] = {}
    words = query.lower().split('    ')
    rw = rep['words']
    used = {}
    for w in words:
        if (len(self.dictionary.freqs()) > 0):
            rw[w] = (1.0 / (1.0 + math.log((1.0 + self.dictionary.freqs()[w]))))
        elif (w not in stopwords):
            rw[w] = 1
        used[w] = True
    norm = len(used)
    rep['norm'] = math.sqrt(len(words))
    return rep
