diff --git a/frontend/src/utils/trie.js b/frontend/src/utils/trie.js index 86a54f5..a869cd5 100644 --- a/frontend/src/utils/trie.js +++ b/frontend/src/utils/trie.js @@ -41,7 +41,7 @@ export class Trie { return this.get(key) !== null } - greedyMatch(str) { + lazyMatch(str) { let node = this._root for (let char of str) { let nextNode = node.children[char] diff --git a/frontend/src/views/Room.vue b/frontend/src/views/Room.vue index 62e8c47..d6134df 100644 --- a/frontend/src/views/Room.vue +++ b/frontend/src/views/Room.vue @@ -272,7 +272,7 @@ export default { let blockKeywordsTrie = this.blockKeywordsTrie for (let i = 0; i < content.length; i++) { let remainContent = content.substring(i) - if (blockKeywordsTrie.greedyMatch(remainContent) !== null) { + if (blockKeywordsTrie.lazyMatch(remainContent) !== null) { return false } } @@ -327,7 +327,7 @@ export default { let pos = 0 while (pos < data.content.length) { let remainContent = data.content.substring(pos) - let matchEmoticon = emoticonsTrie.greedyMatch(remainContent) + let matchEmoticon = emoticonsTrie.lazyMatch(remainContent) if (matchEmoticon === null) { pos++ continue diff --git a/services/translate.py b/services/translate.py index d85c06d..bc7fd9b 100644 --- a/services/translate.py +++ b/services/translate.py @@ -446,7 +446,7 @@ class TencentTranslate(FlowControlTranslateProvider): logger.warning('TencentTranslate request failed: status=%d %s', r.status, r.reason) return None data = (await r.json())['Response'] - except (aiohttp.ClientError, asyncio.TimeoutError): + except (aiohttp.ClientConnectionError, asyncio.TimeoutError): return None error = data.get('Error', None) if error is not None: @@ -554,7 +554,7 @@ class BaiduTranslate(FlowControlTranslateProvider): logger.warning('BaiduTranslate request failed: status=%d %s', r.status, r.reason) return None data = await r.json() - except (aiohttp.ClientError, asyncio.TimeoutError): + except (aiohttp.ClientConnectionError, asyncio.TimeoutError): return None error_code = data.get('error_code', None) if error_code is not None: