parent
aeb774a8ed
commit
789d2a5687
|
@ -41,6 +41,7 @@ static double Score(size_t eventCount,
|
||||||
double eventTimestamp,
|
double eventTimestamp,
|
||||||
double timestamp,
|
double timestamp,
|
||||||
double lambda);
|
double lambda);
|
||||||
|
static bool IsEndingPunctuation(const string& value);
|
||||||
static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
||||||
size_t cursorIndex);
|
size_t cursorIndex);
|
||||||
|
|
||||||
|
@ -141,6 +142,10 @@ static double Score(size_t eventCount,
|
||||||
return prob * decay;
|
return prob * decay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsEndingPunctuation(const string& value) {
|
||||||
|
return value == "," || value == "。" || value== "!" || value == "?" ||
|
||||||
|
value == "」" || value == "』" || value== "”" || value == "”";
|
||||||
|
}
|
||||||
static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
||||||
size_t cursorIndex) {
|
size_t cursorIndex) {
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
|
@ -169,12 +174,18 @@ static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
||||||
s.clear();
|
s.clear();
|
||||||
s.str(std::string());
|
s.str(std::string());
|
||||||
if (r != n.rend()) {
|
if (r != n.rend()) {
|
||||||
|
string value = (*r).node->currentKeyValue().value;
|
||||||
|
if (IsEndingPunctuation(value)) {
|
||||||
|
s << "()";
|
||||||
|
r = n.rend();
|
||||||
|
} else {
|
||||||
s << "("
|
s << "("
|
||||||
<< (*r).node->currentKeyValue().key
|
<< (*r).node->currentKeyValue().key
|
||||||
<< ","
|
<< ","
|
||||||
<< (*r).node->currentKeyValue().value
|
<< value
|
||||||
<< ")";
|
<< ")";
|
||||||
++r;
|
++r;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
s << "()";
|
s << "()";
|
||||||
}
|
}
|
||||||
|
@ -183,12 +194,18 @@ static string WalkedNodesToKey(const std::vector<NodeAnchor>& walkedNodes,
|
||||||
s.clear();
|
s.clear();
|
||||||
s.str(std::string());
|
s.str(std::string());
|
||||||
if (r != n.rend()) {
|
if (r != n.rend()) {
|
||||||
|
string value = (*r).node->currentKeyValue().value;
|
||||||
|
if (IsEndingPunctuation(value)) {
|
||||||
|
s << "()";
|
||||||
|
r = n.rend();
|
||||||
|
} else {
|
||||||
s << "("
|
s << "("
|
||||||
<< (*r).node->currentKeyValue().key
|
<< (*r).node->currentKeyValue().key
|
||||||
<< ","
|
<< ","
|
||||||
<< (*r).node->currentKeyValue().value
|
<< value
|
||||||
<< ")";
|
<< ")";
|
||||||
++r;
|
++r;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
s << "()";
|
s << "()";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue