MCPcopy Index your code
hub / github.com/clips/pattern / answer

Method answer

pattern/web/__init__.py:1355–1368  ·  view source on GitHub ↗

Returns a DuckDuckGo answer for the given string (e.g., math, spelling, ...)

(self, string, **kwargs)

Source from the content-addressed store, hash-verified

1353 return results
1354
1355 def answer(self, string, **kwargs):
1356 """ Returns a DuckDuckGo answer for the given string (e.g., math, spelling, ...)
1357 """
1358 url = URL(DUCKDUCKGO, method=GET, query={
1359 "q": string,
1360 "o": "json"
1361 })
1362 kwargs.setdefault("cached", False)
1363 kwargs.setdefault("unicode", True)
1364 kwargs.setdefault("throttle", self.throttle)
1365 data = url.download(**kwargs)
1366 data = json.loads(data)
1367 data = data.get(kwargs.get("field", "Answer"))
1368 return u(data)
1369
1370 def spelling(self, string):
1371 """ Returns a list of spelling suggestions for the given string.

Callers 2

spellingMethod · 0.95
definitionMethod · 0.95

Calls 4

downloadMethod · 0.95
URLClass · 0.85
setdefaultMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected