mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-17 16:19:13 +00:00
feat: keep German, French and Spanish interest phrases out of the positive path when a negating word appears anywhere earlier in the sentence, and drop the infinitive scheduling phrases termin vereinbaren, fixer un rendez-vous, agendar and programar una llamada that read the same inside a refusal
This commit is contained in:
@@ -234,7 +234,7 @@ The reading before any call covers:
|
||||
- **Out-of-office replies**, recognized by the subject their mail provider writes (`Автоматический ответ`, `自動応答`, `자동 회신`, `رد تلقائي` and so on) and decided with no call at all.
|
||||
- **Non-delivery notices**, by the subject Exchange writes in Spanish, Italian, Dutch and Portuguese. A notice carrying a delivery-status report is recognized in any language without this.
|
||||
- **Replies that say no**, in German, French, Spanish, Dutch, Italian and Portuguese: a declined interest ("kein Interesse", "pas intéressé", "no me interesa", "geen interesse", "non sono interessato", "não tenho interesse") or another clear no ("nein danke", "non merci", "no gracias", "nee bedankt", "no grazie", "não, obrigado", "falscher Ansprechpartner", "persona sbagliata"). Each phrase is matched as whole words, so "no grazie" never matches inside "buono, grazie". The reply classifier reads these as negative with no call, the same verdict "not interested" and "no thanks" get in English, so they take the `reply_negative` branch. Inbox labels still come from the classifier.
|
||||
- **Replies that show interest**, in German, French and Spanish ("klingt gut", "lassen Sie uns telefonieren", "ça m'intéresse", "je suis intéressé", "me interesa mucho", "agendemos una llamada"), read as positive with no call, the same verdict "interested" and "let's talk" get in English, so they take the `reply_positive` branch and count as interested leads. A reply that also says no in one of these languages ("klingt gut, aber kein Bedarf") stays negative, and a phrase straight after "no", "nicht", "pas" and the like ("no me interesa mucho") does not count.
|
||||
- **Replies that show interest**, in German, French and Spanish ("klingt gut", "lassen Sie uns telefonieren", "ça m'intéresse", "je suis intéressé", "me interesa mucho", "agendemos una llamada"), read as positive with no call, the same verdict "interested" and "let's talk" get in English, so they take the `reply_positive` branch and count as interested leads. A reply that also says no in one of these languages ("klingt gut, aber kein Bedarf") stays negative, and a phrase in a sentence that already says "no", "nicht", "pas" and the like ("no me interesa mucho", "je ne crois pas, honnêtement, que cela nous intéresse") does not count.
|
||||
|
||||
Tagging languages are part of the workspace settings, so they travel with a [workspace export](/guides/workspace-export-import/).
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ type langRules struct {
|
||||
// negative is any other clear no. Both are phrases, never single words.
|
||||
declined, negative []string
|
||||
// positive is clear interest. A chosen language's is read after its no
|
||||
// phrases, and never shortly after a negating word. positiveAsWritten
|
||||
// phrases, and never in a sentence with a negating word before it. positiveAsWritten
|
||||
// keeps its accents, where folding would change the meaning.
|
||||
positive, positiveAsWritten []string
|
||||
}
|
||||
@@ -146,7 +146,7 @@ var languageRules = map[string]langRules{
|
||||
},
|
||||
positive: []string{
|
||||
"klingt gut", "klingt interessant", "klingt spannend", "ich bin interessiert", "wir sind interessiert",
|
||||
"lassen sie uns telefonieren", "lass uns telefonieren", "können wir telefonieren", "termin vereinbaren",
|
||||
"lassen sie uns telefonieren", "lass uns telefonieren", "können wir telefonieren",
|
||||
"gerne mehr erfahren", "schicken sie mir mehr informationen", "was kostet das",
|
||||
},
|
||||
},
|
||||
@@ -167,7 +167,7 @@ var languageRules = map[string]langRules{
|
||||
positive: []string{
|
||||
"je suis intéressé", "je suis intéressée", "nous sommes intéressés", "nous sommes intéressées",
|
||||
"ça m'intéresse", "cela m'intéresse", "ça nous intéresse", "cela nous intéresse",
|
||||
"ça a l'air intéressant", "cela semble intéressant", "prenons rendez-vous", "fixer un rendez-vous",
|
||||
"ça a l'air intéressant", "cela semble intéressant", "prenons rendez-vous",
|
||||
"envoyez-moi plus d'informations", "envoyez-moi une offre", "envoyez-moi un devis",
|
||||
"quel est le tarif", "quels sont vos tarifs",
|
||||
},
|
||||
@@ -187,8 +187,8 @@ var languageRules = map[string]langRules{
|
||||
},
|
||||
positive: []string{
|
||||
"me interesa mucho", "nos interesa mucho", "estoy muy interesado",
|
||||
"estoy muy interesada", "estamos muy interesados", "agendemos una llamada", "agendar una llamada",
|
||||
"programar una llamada", "envíeme más información", "envíame más información", "cuánto cuesta",
|
||||
"estoy muy interesada", "estamos muy interesados", "agendemos una llamada",
|
||||
"envíeme más información", "envíame más información", "cuánto cuesta",
|
||||
"cuál es el precio",
|
||||
},
|
||||
// "Si me interesa, les aviso" is conditional; only the accented "sí" says yes.
|
||||
@@ -464,43 +464,29 @@ type ruleSet struct {
|
||||
type phrase struct {
|
||||
text string
|
||||
bounded bool
|
||||
// negatable phrases do not count after a negating word in the same clause ("no me interesa mucho").
|
||||
// negatable phrases do not count after a negating word in the same sentence ("no me interesa mucho").
|
||||
negatable bool
|
||||
// asWritten phrases keep their accents, because folding them changes the meaning ("sí" is not "si").
|
||||
asWritten bool
|
||||
}
|
||||
|
||||
// negators are the words that, shortly before an interest phrase, turn it around.
|
||||
// negators are the words that, earlier in the sentence, turn an interest phrase around.
|
||||
var negators = map[string]bool{
|
||||
"no": true, "not": true, "nicht": true, "kein": true, "keine": true, "keinen": true, "nie": true,
|
||||
"pas": true, "ne": true, "non": true, "niet": true, "geen": true, "nao": true, "nunca": true, "jamas": true,
|
||||
}
|
||||
|
||||
// negationWindow is how many words back a negator still reaches ("no quiero agendar una llamada").
|
||||
const negationWindow = 3
|
||||
|
||||
// negatedAt reports a negator within negationWindow words before start. Words are
|
||||
// separated by any whitespace; punctuation ends the clause, and the search with it.
|
||||
// negatedAt reports a negator earlier in the sentence that holds start. Commas and
|
||||
// line breaks do not end it ("je ne crois pas, honnêtement, que cela nous intéresse").
|
||||
func negatedAt(text string, start int) bool {
|
||||
head := text[:start]
|
||||
for range negationWindow {
|
||||
head = strings.TrimRightFunc(head, unicode.IsSpace)
|
||||
end := len(head)
|
||||
for end > 0 {
|
||||
r, size := utf8.DecodeLastRuneInString(head[:end])
|
||||
if !unicode.IsLetter(r) {
|
||||
break
|
||||
}
|
||||
end -= size
|
||||
}
|
||||
word := head[end:]
|
||||
if word == "" {
|
||||
return false
|
||||
}
|
||||
if i := strings.LastIndexAny(head, ".!?;"); i >= 0 {
|
||||
head = head[i+1:]
|
||||
}
|
||||
for _, word := range strings.FieldsFunc(head, func(r rune) bool { return !unicode.IsLetter(r) }) {
|
||||
if negators[word] {
|
||||
return true
|
||||
}
|
||||
head = head[:end]
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -248,6 +248,10 @@ func TestNegatedAndHedgedInterestIsNotPositive(t *testing.T) {
|
||||
"No\nme interesa mucho.",
|
||||
"No quiero agendar una llamada.",
|
||||
"Wir wollen nicht gleich einen Termin vereinbaren.",
|
||||
"Ich glaube nicht, dass wir einen Termin vereinbaren sollten.",
|
||||
"No me parece buena idea programar una llamada.",
|
||||
"No sé todavía si nos interesa mucho.",
|
||||
"Je ne crois pas, honnêtement, que cela nous intéresse.",
|
||||
} {
|
||||
if got := ClassifyOffline(Input{Subject: "Re: Hallo", BodyText: body, Languages: all}); got.Class == ClassPositive {
|
||||
t.Errorf("%q read as positive", body)
|
||||
@@ -255,24 +259,20 @@ func TestNegatedAndHedgedInterestIsNotPositive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A negating word straight before the phrase turns it around; anything else between does not.
|
||||
func TestNegatedAtReadsTheWordBefore(t *testing.T) {
|
||||
// A negating word anywhere earlier in the sentence turns the phrase around.
|
||||
func TestNegatedAtReadsTheSentence(t *testing.T) {
|
||||
for text, want := range map[string]bool{
|
||||
"no me interesa mucho": true,
|
||||
"nicht klingt gut": true,
|
||||
"no, me interesa mucho": false,
|
||||
"bueno me interesa mucho": false,
|
||||
"me interesa mucho": false,
|
||||
"pero no me interesa mucho": true,
|
||||
"no\nme interesa mucho": true,
|
||||
"no quiero me interesa mucho": true,
|
||||
"no a b c me interesa mucho": false,
|
||||
"no me interesa mucho": true,
|
||||
"no, me interesa mucho": true,
|
||||
"pero no me interesa mucho": true,
|
||||
"no\nme interesa mucho": true,
|
||||
"no a b c me interesa mucho": true,
|
||||
"bueno me interesa mucho": false,
|
||||
"me interesa mucho": false,
|
||||
"no. me interesa mucho": false,
|
||||
"por que no? me interesa mucho": false,
|
||||
} {
|
||||
start := len(text) - len("me interesa mucho")
|
||||
if text == "nicht klingt gut" {
|
||||
start = len("nicht ")
|
||||
}
|
||||
if got := negatedAt(text, start); got != want {
|
||||
if got := negatedAt(text, len(text)-len("me interesa mucho")); got != want {
|
||||
t.Errorf("negatedAt(%q) = %v, want %v", text, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user