<commit_before>package Kinsokujiko

// Item is dictionary Item
type Item struct {
	Surf  string
	Slice string
	Kana  string
	Pos   string
}

// Dictionary is Slice any Item
type Dictionary []Item

var dicPaht = "_dic/dic.txt"<commit_msg>add methods for dictionary function.<commit_after>package Kinsokujiko

import (
	"errors"
	"fmt"
	"os"
	"strings"
)

// Item is dictionary Item
type Item struct {
	Surf  string
	Slice string
	Kana  string
	Pos   string
}

// Dictionary is Slice any Item
type Dictionary []Item

var dicPath = "_dic/dic.txt"

func Update(dic Dictionary) (bool, error) {
	_, err := _add_item(dic)
	if err != nil {
		fmt.Print(err)
	}
	for index, item := range dic {
		if !_check_item(item) {
			return false, errors.New(fmt.Sprintf("%d 行目に問題があるようです", index))
		}
	}
	return _add_item(dic)
}

func _check_item(it Item) bool {
	var res = false
	if strings.Count(it.Surf, "") > 1 {
		res = true
	}
	if strings.Count(it.Slice, "") > 1 {
		res = true
	}
	if strings.Count(it.Kana, "") > 1 {
		res = true
	}
	if strings.Count(it.Pos, "") > 1 {
		res = true
	}
	return res
}

func _add_item(dic Dictionary) (bool, error) {
	file, err := os.OpenFile(dicPath, os.O_RDWR|os.O_CREATE, 0755)
	if err != nil {
	}
	defer file.Close()
	fmt.Sprintf("ファイルの詳細：%+v", file)
	return true, nil
}

func Show() (Dictionary, error) {
	return Dictionary{}, nil
}

func _get_dic() {}
{'fraction_non_alphanumeric': 0.1331877729257642, 'fraction_numerical': 0.005822416302765648, 'mean_word_length': 3.523026315789474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1011693', 'n_tokens_mistral': 566, 'n_tokens_neox': 546, 'n_words': 147}