Metadata: Update folder_test.go, photo_estimate_test.go, country_test.go

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-09-26 11:44:27 +02:00
parent 4d91f5ffdf
commit a3dac7c707
4 changed files with 36 additions and 3 deletions

View File

@@ -9,6 +9,35 @@ var UnknownStateCode = "zz"
var UnknownCountryCode = "zz"
var CountryWordsRegexp = regexp.MustCompile("[\\p{L}]{2,}")
// AmbiguousCountries contains location keywords that also occur as popular given names.
// They require additional context before we can safely treat them as country hints.
var AmbiguousCountries = map[string]string{
"vienna": "at",
"london": "gb",
"sydney": "au",
"dallas": "us",
"houston": "us",
"orlando": "us",
"jordan": "jo",
"rafic hariri": "lb",
"sofia": "bg",
"sana'a": "ye",
"sanaa": "ye",
"sana a": "ye",
"riad": "sa",
"riyadh": "sa",
"milan": "it",
"venice": "it",
"trinidad": "tt",
"valencia": "es",
"alberta": "ca",
"ben gurion": "il",
"haifa": "il",
"paris": "fr",
"chad": "td",
"samaria": "ps",
}
// CountryCode attempts to find a matching country code for a given string.
func CountryCode(s string) (code string) {
code = UnknownCountryCode

View File

@@ -43,6 +43,10 @@ func TestCountryCode(t *testing.T) {
result := CountryCode("I was in Los Angeles")
assert.Equal(t, "us", result)
})
t.Run("Brandenburg", func(t *testing.T) {
result := CountryCode("Trip to Brandenburg in Spring")
assert.Equal(t, "de", result)
})
t.Run("Melbourne", func(t *testing.T) {
result := CountryCode("The name Narrm is commonly used by the broader Aboriginal community\n\rto refer to the city, \t stemming from the traditional name recorded for the area on which the Melbourne city centre is built.")
assert.Equal(t, "au", result)