Commit cf70c28f authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[Autofill][Slimshady] Refined expressions for Spanish/Hispanic names

Change-Id: I77d17601928655d563cab39daf5ba9c04f97fbde
Bug: 1099202
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362911
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarChristoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#799144}
parent 0e9a9078
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/form_parsing/autofill_scanner.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h"
#include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_regex_constants.h"
#include "components/autofill/core/common/autofill_regexes.h"
#include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/form_field_data.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -529,4 +531,41 @@ TEST_F(NameFieldTest, MiddleInitialAtEnd) { ...@@ -529,4 +531,41 @@ TEST_F(NameFieldTest, MiddleInitialAtEnd) {
field_candidates_map_[ASCIIToUTF16("name3")].BestHeuristicType()); field_candidates_map_[ASCIIToUTF16("name3")].BestHeuristicType());
} }
// Test the coverage of all found strings for first and second last names.
TEST_F(NameFieldTest, HispanicLastNameRegexConverage) {
std::vector<std::string> first_last_name_strings = {
"Primer apellido", "apellidoPaterno", "apellido_paterno",
"first_surname", "first surname", "apellido1"};
std::vector<std::string> second_last_name_strings = {
"Segundo apellido", "apellidoMaterno", "apellido_materno",
"apellido2", "second_surname", "second surname",
};
std::vector<std::string> neither_first_or_second_last_name_strings = {
"apellido",
"apellidos",
};
for (const auto& string : first_last_name_strings) {
SCOPED_TRACE(string);
EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(string),
ASCIIToUTF16(kNameLastFirstRe), nullptr));
}
for (const auto& string : second_last_name_strings) {
SCOPED_TRACE(string);
EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(string),
ASCIIToUTF16(kNameLastSecondRe), nullptr));
}
for (const auto& string : neither_first_or_second_last_name_strings) {
SCOPED_TRACE(string);
EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(string),
ASCIIToUTF16(kNameLastFirstRe), nullptr));
EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(string),
ASCIIToUTF16(kNameLastSecondRe), nullptr));
}
}
} // namespace autofill } // namespace autofill
...@@ -333,13 +333,15 @@ const char kLastNameRe[] = ...@@ -333,13 +333,15 @@ const char kLastNameRe[] =
"|(\\b|_|\\*)(soyisim|soyad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr "|(\\b|_|\\*)(soyisim|soyad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr
"|\\b성(?:[^명]|\\b)"; // ko-KR "|\\b성(?:[^명]|\\b)"; // ko-KR
const char kNameLastFirstRe[] = const char kNameLastFirstRe[] =
"(primer.*apellido)" // es "(primer.*apellido)" // es
"|(apellido.*paterno)" // es "|(apellido1)" // es
"|surname_?1|first_?surname"; // es "|(apellido.*paterno)" // es
"|surname_?1|first(\\s|_)?surname"; // es
const char kNameLastSecondRe[] = const char kNameLastSecondRe[] =
"(segunda.*apellido)" // es "(segund.*apellido)" // es
"|(apellido.*materno)" // es "|(apellido2)" // es
"|surname_?2|second_?surname"; // es "|(apellido.*materno)" // es
"|surname_?2|second(\\s|_)?surname"; // es
const char kHonorificPrefixRe[] = const char kHonorificPrefixRe[] =
"anrede|titel" // de-DE "anrede|titel" // de-DE
"|tratamiento|encabezamiento" // es "|tratamiento|encabezamiento" // es
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment