<commit_before>package wikiio

import (
	. "github.com/OUCC/syaro/logger"
	"github.com/OUCC/syaro/setting"
	"github.com/OUCC/syaro/util"

	"gopkg.in/fsnotify.v1"

	"errors"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
)

var (
	WikiRoot    *WikiFile
	searchIndex map[string][]*WikiFile
	watcher     fsnotify.Watcher
)

var (
	ErrNotExist = errors.New("file not exist")
	ErrNotFound = errors.New("file not found")
)

func InitWatcher() {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		Log.Fatal(err)
	}

	// event loop for watcher
	go func() {
		for {
			select {
			case event := <-watcher.Events:
				Log.Debug("%s", event)<commit_msg>[FIX] can't close fs watcher<commit_after>package wikiio

import (
	. "github.com/OUCC/syaro/logger"
	"github.com/OUCC/syaro/setting"
	"github.com/OUCC/syaro/util"

	"gopkg.in/fsnotify.v1"

	"errors"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
)

var (
	WikiRoot    *WikiFile
	searchIndex map[string][]*WikiFile
	watcher     *fsnotify.Watcher
)

var (
	ErrNotExist = errors.New("file not exist")
	ErrNotFound = errors.New("file not found")
)

func InitWatcher() {
	var err error
	watcher, err = fsnotify.NewWatcher()
	if err != nil {
		Log.Fatal(err)
	}

	// event loop for watcher
	go func() {
		for {
			select {
			case event := <-watcher.Events:
				Log.Debug("%s", event)
{'fraction_non_alphanumeric': 0.15286144578313254, 'fraction_numerical': 0.0015060240963855422, 'mean_word_length': 3.5050847457627117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1499086', 'n_tokens_mistral': 584, 'n_tokens_neox': 544, 'n_words': 106}