# Censor words should support sentence level censoring for Chinese

**URL:** https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288
**Category:** Feature
**Created:** [2017 年 10 月 3 日午前 5:41 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288 "2017-10-03T05:41:39Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [2017 年 10 月 3 日午前 5:41 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/1 "2017-10-03T05:41:39Z")

</div>

CJKV doesn’t have word boundaries. It’s more reliable to use the feature with a sentence level. In a word, support this feature without word boundaries.

Suggested: (Chinese) [https://meta.discoursecn.org/t/topic/2175?u=fantasticfears](https://meta.discoursecn.org/t/topic/2175?u=fantasticfears)

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017 年 10 月 3 日午前 6:13 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/2 "2017-10-03T06:13:05Z")

</div>

There is a discussion here:

> [@Censored pattern](https://meta.discourse.org/t/censored-pattern/66912/6):
>
> @sam is correct in that \b doesn’t seem to match any Unicode, or any non-ASCII word breaks. \w seems to be defined narrowly as [A-Za-z0-9\_], probably just to parse source-code type texts. And \b is simply (\w\W|\W\w). So using \b has the net effect of turning any character outside simple ASCII letters/digits into white-space letters. There doesn’t seem to be an easy way out to deal with this. An option to deal with this is to omit the \b wrapping altogether – a good idea because this will n…

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017 年 10 月 3 日午前 6:35 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/4 "2017-10-03T06:35:15Z")

</div>

If you can do a custom build of discourse, it is a simple matter to change that one line of code to remove the wrapping `\b`’s.

In the long term, I suggest removing them as default, or at least add a site setting for those of us running non-English forums.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2017 年 10 月 3 日午後 1:47 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/5 "2017-10-03T13:47:27Z")

</div>

You could create a plugin to do that and/or submit a PR.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017 年 10 月 3 日午後 1:50 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/6 "2017-10-03T13:50:12Z")

</div>

Unfortunately a plugin requires quite a bit of Ruby knowledge. I can debug, but probably not even close to writing plugins.

A PR would require that I fork the entire repo, which is ok except I have no way to test it. It is bad form to submit a PR without testing…

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [2017 年 10 月 3 日午後 2:51 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/7 "2017-10-03T14:51:18Z")

</div>

> [@schungx](#):
>
> If you can do a custom build of discourse, it is a simple matter to change that one line of code to remove the wrapping \b’s.

There’s really not enough to remove one line. It is necessary to completely rewrite the logic file. I gave there a working version of the file (using loops).

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017 年 10 月 4 日午後 4:17 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/8 "2017-10-04T16:17:06Z")

</div>

Well, not to remove the line, but to remove the `\b`’s in the line.

Regexp will never work for all languages with word breaks. The best you can do is to allow the user to decide which words require word breaks and which do not.

With the `\b` wrapper hard-coded in right now, there is no choice.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2018 年 1 月 11 日午前 5:50 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/9 "2018-01-11T05:50:57Z")

</div>

This issue is now solved by:

> [@\* wildcards in Watched Words (Censor) don't work](https://meta.discourse.org/t/wildcards-in-watched-words-censor-dont-work/77007/21):
>
> Prelim testing shows that it is working perfectly fine! Good job! Now finally I can censor Chinese! tada

To match Chinese patterns, turn on `Settings > Posting > watched words regular expressions`.

Beware, your `Watched Words` will now be raw regular expressions, so if your list includes English words, you’ll need to put in your own word break `\b` where necessary.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2018 年 1 月 12 日午後 11:00 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/10 "2018-01-12T23:00:11Z")

</div>

This topic was automatically closed after 40 hours. New replies are no longer allowed.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2026 年 2 月 16 日午後 2:45 UTC](https://meta.discourse.org/t/censor-words-should-support-sentence-level-censoring-for-chinese/71288/11 "2026-02-16T14:45:35Z")

</div>

おかげさまで、[FIX: support CJK and spaceless scripts in watched word boundaries by ZogStriP · Pull Request #37844 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/37844) により、中国語の適切な「単語境界」処理が実現しました。
