Example #1
0
 def score(self, root_cmd, word):
     if self.type == "seq":
         return sum(part.score(root_cmd, word) for part in self.info)
     elif self.type == "case":
         return max(part.score(root_cmd, word) for part in self.info)
     elif self.type == "empty":
         return 0
     elif self.type == "arg":
         argname = common.mangle_arg(root_cmd, self.info[0])
         return scores.get(word, {}).get(argname, 0) * (1-code_freqs.get(argname, 0))
     elif self.type == "hole":
         return 0
Example #2
0
 def score(self, root_cmd, word):
     if self.type == "seq":
         return sum(part.score(root_cmd, word) for part in self.info)
     elif self.type == "case":
         return max(part.score(root_cmd, word) for part in self.info)
     elif self.type == "empty":
         return 0
     elif self.type == "arg":
         argname = common.mangle_arg(root_cmd, self.info[0])
         return scores.get(word, {}).get(
             argname, 0) * (1 - code_freqs.get(argname, 0))
     elif self.type == "hole":
         return 0
Example #3
0
def score_tool_name(word, tool_name):
    return (1-word_freqs.get(word, 0)) * scores.get(word, EMPTY).get(tool_name, 0) * (1-code_freqs.get(tool_name, 0))
Example #4
0
def score_tool_name(word, tool_name):
    return (1 - word_freqs.get(word, 0)) * scores.get(word, EMPTY).get(
        tool_name, 0) * (1 - code_freqs.get(tool_name, 0))