-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter.cpp
61 lines (51 loc) · 1.68 KB
/
Character.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <map>
#include <vector>
#include <string>
#include <random>
#include <set>
#include <mecab.h>
#include <regex>
#include "MTable.h"
#include "Analyze.h"
#include "RuleBase.h"
#include "Character.h"
Character::Character(void){
}
Character::Character(const std::string& MTablePath, const std::string& RegexPath, const std::string& SerifPath):mtable(MTablePath), rulebase(RegexPath, SerifPath){
}
Character::~Character(void){
}
std::string Character::Respond(const std::string& input){
std::string res;
if(rulebase.nextIsMarkov()){
res=mtable.makeSentenceRand();
}
if(!res.empty())return res;
analyzer.AnalyzeString(input);
std::vector<std::string> words=analyzer.extractIndependent();//活用形をもっと豊富にしたいよね
/*if(words.empty())return rulebase.respondRuleBase(input,words);
res = mtable.respondMarkov(words);
return res.empty()?rulebase.respondRuleBase(input,words):res;*/
return rulebase.respondRuleBase(input,words);
}
std::string Character::RespondF(const std::string& input){
std::string res;
if(rulebase.nextIsMarkov()){
res=mtable.makeSentenceRand();
}
if(!res.empty())return res;
analyzer.AnalyzeString(input);
std::vector<std::string> words=analyzer.extractIndependent();//活用形をもっと豊富にしたいよね
/*if(words.empty())return rulebase.respondRuleBase(input,words);
res = mtable.respondMarkov(words);
return res.empty()?rulebase.respondRuleBase(input,words):res;*/
return rulebase.respondRuleBaseF(input,words);
}
std::string Character::ForceRespond(const std::string& input){
std::string res;
if(rulebase.nextIsMarkov()){
res=mtable.makeSentenceRand();
}
if(!res.empty())return res;
return rulebase.replySilence();
}