PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: PyThaiNLP/pythainlp (python)
Issue: countthai not cover all cases
**Describe the bug**
Input countthai('123') or countthai(' ') or countthai('1 2 3 4') create error instead of zero? 

**To Reproduce**
Steps to reproduce the behavior:
1. from pythainlp.util import countthai
2. input either '123' or ' '

**Expected behavior**
it should return zero?
Pull request description: Make countthai() to cover a case that the text has only ignore_chars
This PR will close #398 

Prevent divide by zero

Patch:
diff --git a/pythainlp/util/thai.py b/pythainlp/util/thai.py
index 1a78dc32..b141b260 100644
--- a/pythainlp/util/thai.py
+++ b/pythainlp/util/thai.py
@@ -127,7 +127,7 @@ def countthai(text: str, ignore_chars: str = _DEFAULT_IGNORE_CHARS) -> float:
         # output: 0.0
     """
     if not text or not isinstance(text, str):
-        return 0
+        return 0.0
 
     if not ignore_chars:
         ignore_chars = ""
@@ -143,4 +143,7 @@ def countthai(text: str, ignore_chars: str = _DEFAULT_IGNORE_CHARS) -> float:
 
     num_count = len(text) - num_ignore
 
+    if num_count == 0:
+        return 0.0
+
     return (num_thai / num_count) * 100


Test patch:
diff --git a/tests/test_util.py b/tests/test_util.py
index 34d2491e..958fa201 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -340,8 +340,11 @@ class TestUtilPackage(unittest.TestCase):
     # ### pythainlp.util.thai
 
     def test_countthai(self):
-        self.assertEqual(countthai(""), 0)
+        self.assertEqual(countthai(""), 0.0)
+        self.assertEqual(countthai("123"), 0.0)
+        self.assertEqual(countthai("1 2 3"), 0.0)
         self.assertEqual(countthai("ประเทศไทย"), 100.0)
+        self.assertEqual(countthai("โรค COVID-19"), 37.5)
         self.assertEqual(countthai("(กกต.)", ".()"), 100.0)
         self.assertEqual(countthai("(กกต.)", None), 50.0)