File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ defmodule HaloSir.Rules do
7
7
Don't cache sentences.
8
8
"""
9
9
def should_cache_word? ( word ) do
10
- not_too_long? ( word ) && not_sentence? ( word )
10
+ not_too_long? ( word ) && not_sentence? ( word ) && has_english_letter? ( word )
11
11
end
12
12
13
13
defp not_sentence? ( word ) do
@@ -20,4 +20,9 @@ defmodule HaloSir.Rules do
20
20
defp not_too_long? ( word ) do
21
21
String . length ( word ) <= 20
22
22
end
23
+
24
+ @ reg ~r/ [a-zA-Z]/
25
+ defp has_english_letter? ( word ) do
26
+ Regex . match? ( @ reg , word )
27
+ end
23
28
end
Original file line number Diff line number Diff line change @@ -25,4 +25,10 @@ defmodule HaloSir.RulesTest do
25
25
26
26
refute should_cache_word? ( sentence )
27
27
end
28
+
29
+ test "Should not cache words with no English letter" do
30
+ word = "『氷菓』"
31
+
32
+ refute should_cache_word? ( word )
33
+ end
28
34
end
You can’t perform that action at this time.
0 commit comments