Get the argmax of a variable :param variable: a variable :param relation: a relation :return: the argmax of a variable
(variable: str, attribute: str, sparql_executor)
| 173 | |
| 174 | |
| 175 | def argmax(variable: str, attribute: str, sparql_executor): |
| 176 | """ |
| 177 | Get the argmax of a variable |
| 178 | :param variable: a variable |
| 179 | :param relation: a relation |
| 180 | :return: the argmax of a variable |
| 181 | """ |
| 182 | # program = f"(ARGMAX {variable} {attribute})" |
| 183 | # processed_code = postprocess_raw_code(program) |
| 184 | # sparql_query = lisp_to_sparql(processed_code) |
| 185 | # answers = execute_query(sparql_query) |
| 186 | if attribute not in variable_attributes_cache[variable]: |
| 187 | raise ValueError("argmax: attribute must be an attribute of the variable") |
| 188 | |
| 189 | rtn_str = f"Observation: variable ##, which are instances of {variable.type}" |
| 190 | new_variable = Variable(variable.type, f"(ARGMAX {variable.program} {attribute})") |
| 191 | return new_variable, rtn_str |
| 192 | |
| 193 | |
| 194 | def argmin(variable: str, attribute: str, sparql_executor): |