MCPcopy
hub / github.com/PDFMathTranslate/PDFMathTranslate / translate

Method translate

pdf2zh/translator.py:90–103  ·  view source on GitHub ↗

Translate the text, and the other part should call this method. :param text: text to translate :return: translated text

(self, text: str, ignore_cache: bool = False)

Source from the content-addressed store, hash-verified

88 self.cache.add_params(k, v)
89
90 def translate(self, text: str, ignore_cache: bool = False) -> str:
91 """
92 Translate the text, and the other part should call this method.
93 :param text: text to translate
94 :return: translated text
95 """
96 if not (self.ignore_cache or ignore_cache):
97 cache = self.cache.get(text)
98 if cache is not None:
99 return cache
100
101 translation = self.do_translate(text)
102 self.cache.set(text, translation)
103 return translation
104
105 def do_translate(self, text: str) -> str:
106 """

Callers 6

test_cacheMethod · 0.45
do_translateMethod · 0.45
translateMethod · 0.45
workerMethod · 0.45

Calls 3

do_translateMethod · 0.95
getMethod · 0.45
setMethod · 0.45

Tested by 3

test_cacheMethod · 0.36