You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2020/11/23 04:53:24 UTC

[incubator-echarts-bot] 02/02: tweak: do not add en label when issue contains over 5 Chinese characters.

This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-bot.git

commit 5510b947678e0ded614ff7e798c2a6144911869d
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Mon Nov 23 12:52:59 2020 +0800

    tweak: do not add en label when issue contains over 5 Chinese characters.
---
 src/issue.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/issue.js b/src/issue.js
index efcbe60..6139a36 100644
--- a/src/issue.js
+++ b/src/issue.js
@@ -1,6 +1,9 @@
 const text = require('./text');
 const { isCommitter } = require('./coreCommitters');
 
+const REG_CHN_CHAR = /[\u4e00-\u9fa5]/g;
+const MAX_CHN_CHAR_COUNT = 5;
+
 class Issue {
     constructor(context) {
         this.context = context;
@@ -57,7 +60,7 @@ class Issue {
         this.addLabels.push(this.issueType);
 
         const isInEnglish = this._contain('This issue is in English');
-        if (isInEnglish) {
+        if (isInEnglish && !this._isMainlyUsingChinese()) {
             this.addLabels.push('en');
         }
     }
@@ -65,6 +68,10 @@ class Issue {
     _contain(txt) {
         return this.body.indexOf(txt) > -1;
     }
+
+    _isMainlyUsingChinese() {
+        return this.body.match(REG_CHN_CHAR).length > MAX_CHN_CHAR_COUNT;
+    }
 }
 
 module.exports = Issue;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org