Essacheez's picture
Add 59 code_instruct tasks (20 Qwen3.5-4B, 39 Qwen3.5-9B) (part 2)
d6a0939 verified
Raw History Blame Contribute Delete
973 Bytes
diff --git a/task_module.py b/task_module.py
new file mode 100644
index 0000000..0000001
--- /dev/null
+++ b/task_module.py
@@ -0,0 +1,24 @@
+from pygments.lexers import PythonLexer
+from pygments import token
+
+class CodeAnalyzer:
+ """Analyzes Python code using pygments tokenization."""
+
+ def __init__(self):
+ self._lexer = PythonLexer()
+
+ def count_docstrings(self, source):
+ """Count the number of String.Doc tokens in the source code."""
+ if not isinstance(source, str):
+ raise TypeError("Source must be a string")
+
+ # Get tokens using pygments
+ # Note: get_tokens returns an iterator of (TokenType, value) tuples
+ tokens = list(self._lexer.get_tokens(source))
+
+ count = 0
+ for token_type, value in tokens:
+ if token_type == token.String.Doc:
+ count += 1
+
+ return count
\ No newline at end of file