diff options
author | bptato <nincsnevem662@gmail.com> | 2022-01-24 17:22:42 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-01-24 17:22:42 +0100 |
commit | 7cb534fd1fb2cbd0a338ba22457e18ba8cb57f78 (patch) | |
tree | 83942220b5f4f2fe2ccaaed9861ee1fce0542b86 /src/utils | |
parent | 8cc60eb470bf01ab52c2e52a88d208882a5d5be9 (diff) | |
download | chawan-7cb534fd1fb2cbd0a338ba22457e18ba8cb57f78.tar.gz |
Make non-alphabetic characters break words
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/twtstr.nim | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 3050d50e..e2d06535 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -131,12 +131,6 @@ func toAsciiLower*(str: string): string = func getrune(s: string): Rune = return s.toRunes()[0] -const breakWord = [ - Rune('\n'), Rune('/'), Rune('\\'), Rune(' '), Rune('&'), Rune('='), - Rune('?'), Rune('.'), Rune(';'), Rune('"'), "。".getrune(), "、".getrune(), - "「".getrune(), "」".getrune() -] - func genHexCharMap(): seq[int] = for i in 0..255: case chr(i) @@ -193,15 +187,15 @@ func equalsIgnoreCase*(s1: seq[Rune], s2: string): bool = func equalsIgnoreCase*(s1, s2: string): bool {.inline.} = return s1.cmpIgnoreCase(s2) == 0 -func breaksWord*(r: Rune): bool = - return r in breakWord - func isAlphaAscii*(r: Rune): bool = return int(r) < 256 and isAlphaAscii(char(r)) func isDigitAscii*(r: Rune): bool = return int(r) < 256 and isDigit(char(r)) +func breaksWord*(r: Rune): bool = + return not (r.isDigitAscii() or r.isAlpha()) + func substr*(s: seq[Rune], i, j: int): seq[Rune] = if s.len == 0: return @[] |