forked from zake7749/Chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import os | ||
import sys | ||
sys.path.append(os.path.dirname(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
class Validator(object): | ||
|
||
""" | ||
用於驗證預設匹配結果與實際匹配結果是否有不同 | ||
""" | ||
|
||
def __init__(self): | ||
self.paths = [] | ||
self.sentences = [] | ||
|
||
def loadValiadationData(self, paths_datapath, sentences_datapath): | ||
|
||
self.loadPaths(paths_datapath) | ||
self.loadSentences(sentences_datapath) | ||
|
||
def loadPaths(self, path): | ||
with open(path,'r',encoding='utf-8') as input: | ||
self.paths = [line.strip('\n') for line in input] | ||
|
||
def loadSentences(self, path): | ||
with open(path,'r',encoding='utf-8') as input: | ||
self.sentences = [line.strip('\n') for line in input] | ||
|
||
def valiate(self, match): | ||
|
||
""" | ||
驗證預設分類結果與實際分類結果 | ||
Args: | ||
# match:用於比對的函式,建議採用 console.match,該函式 | ||
# 需要回傳匹配路徑與匹配相似度 | ||
Return : 誤分點的表列 | ||
""" | ||
|
||
miss = 0 | ||
|
||
for i in range(0,len(self.sentences)): | ||
for sentence in self.sentences: | ||
sim,path = match(sentence) | ||
if path != self.paths[i]: | ||
miss += 1 | ||
print("在'%s'中,預期為 %s,實際為 %s" % (sentence,self.paths[i],path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters