We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8efcd70 commit 3aa860eCopy full SHA for 3aa860e
Tool/Sources/TokenEncoder/CharacterTokenCounter.swift
@@ -0,0 +1,7 @@
1
+import Foundation
2
+
3
+public struct CharacterTokenCounter: TokenCounter {
4
+ public func countToken(text: String) -> Int {
5
+ text.count
6
+ }
7
+}
Tool/Sources/TokenEncoder/Tokenizer.swift
@@ -1,11 +1,15 @@
import Foundation
-public protocol TokenEncoder {
+public protocol TokenEncoder: TokenCounter {
func encode(text: String) -> [Int]
}
-public extension TokenEncoder {
+extension TokenEncoder {
8
func countToken(text: String) -> Int {
9
encode(text: text).count
10
11
12
13
+public protocol TokenCounter {
14
+ func countToken(text: String) -> Int
15
0 commit comments