1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-23 04:30:44 +08:00

fs.File -> io.Reader

This commit is contained in:
源文雨
2022-12-03 10:54:06 +08:00
parent 35ac98dc5f
commit 36c17a10b5
11 changed files with 28 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ package dictionary
import (
"bufio"
"io/fs"
"io"
"os"
"strconv"
"strings"
@@ -16,7 +16,7 @@ type DictLoader interface {
AddToken(Token)
}
func loadDictionary(file fs.File) (tokens []Token, err error) {
func loadDictionary(file io.Reader) (tokens []Token, err error) {
scanner := bufio.NewScanner(file)
var token Token
var line string
@@ -44,7 +44,7 @@ func loadDictionary(file fs.File) (tokens []Token, err error) {
}
// LoadDictionary reads the given file and passes all tokens to a DictLoader.
func LoadDictionary(dl DictLoader, file fs.File) error {
func LoadDictionary(dl DictLoader, file io.Reader) error {
tokens, err := loadDictionary(file)
if err != nil {
return err