# Don't allow super long words if there is a word length maximum

**URL:** <https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487>\
**Category:** Support\
**Created:** [2016年五月19日 09:54 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487 "2016-05-19T09:54:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![helperhaps](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helperhaps/32/59201_2.png) [@helperhaps](https://meta.discourse.org/u/helperhaps)\
**Post date:** [2016年五月19日 09:54 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/1 "2016-05-19T09:54:59Z")

</div>

I got an invalid title alert when i create a topic. DIg into the code i found it raised by TextSentinel class. And I have already read this [https://meta.discourse.org/t/are-very-long-words-not-allowed-in-topic-titles/29683/16](https://meta.discourse.org/t/are-very-long-words-not-allowed-in-topic-titles/29683/16). There is a related method in the class.

```plaintext
  def seems_unpretentious?
    # Don't allow super long words if there is a word length maximum
    @opts[:max_word_length].blank? || @text.split(/\s|\/|-|\./).map(&:size).max <= @opts[:max_word_length]
  end

```

I understand what it means. But for other language such as Chinese or Japanese whose word is not splited by blank or something about the patern.

Besides SiteSetting.title\_max\_word\_length’s value is 0 when i leave it blank in the setting panel, so the expression @opts[:max\_word\_length].blank? is always true. it is meaningless.

My users use Chinese more, So I have to set SiteSetting.title\_max\_word\_length as same value as SiteSetting.title\_max\_topic\_title\_length to make it work.

Is there some other way to solve it?

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2016年五月24日 03:08 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/2 "2016-05-24T03:08:07Z")

</div>

@fantasticfears any idea what to do here?

---

<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:** [2016年五月24日 05:44 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/3 "2016-05-24T05:44:27Z")

</div>

For CJK, it is meaningless. Word segmentation algorithm would happily chops a sentence into characters and words whenever it can. Without understanding the sentences, I’m afraid it’s not easy to identify good/bad word.

3 ways to disable it:

1. Put some locale check
2. Put a comment about how to disable it by setting the value to the same as topic length.
3. Add another setting to disable it.

The latter two is much better. Although locale-based site settings should be introduced at some moment for convenience.

BTW, if my mentor @tgxworld agrees, I could ask some pointers about how this can be done at some moment in June:

> [@Setting default site settings and scss based on locale](https://meta.discourse.org/t/setting-default-site-settings-and-scss-based-on-locale/25217):
>
> Site settings The default site setting may not make sense for different language. I’ll list my Chinese(zh\_CN) forum site setting to illustrate: min\_post\_length: 3, default: 20 min\_topic\_title\_length: 4, default: 15 min\_search\_term\_length: 1, default: 3 uncategorized\_description: need translation Chinese characters can express more per word which requires to change the default site setting anyway. If not to do so, Discourse can’t even post moderator post since the character of some translation…

---

<div class="post-metadata">

**Author:** ![helperhaps](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helperhaps/32/59201_2.png) [@helperhaps](https://meta.discourse.org/u/helperhaps)\
**Post date:** [2016年五月27日 08:11 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/4 "2016-05-27T08:11:28Z")

</div>

How about just enabling it when all the characters in title is consisted of ASCII code？

---

<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:** [2016年五月27日 09:18 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/5 "2016-05-27T09:18:45Z")

</div>

I think would have to wait until introducing some Unicode filtering libraries instead of regex. I could take this for 1.6 and Unicode username.

It doesn’t make much sense for checking the ascii part within the Chinese sentences. The only possible use case is a multilingual forum which might need such checks based on the title sequences (still, shouldn’t look into ascii sequences in the Chinese sentences for example)

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2019年一月24日 21:27 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/6 "2019-01-24T21:27:29Z")

</div>



---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [2019年一月24日 21:28 UTC](https://meta.discourse.org/t/dont-allow-super-long-words-if-there-is-a-word-length-maximum/44487/7 "2019-01-24T21:28:55Z")

</div>


