Skip to content

Commit

Permalink
Merge pull request #5 from pablodz/feat/fr
Browse files Browse the repository at this point in the history
fully supported, fix runes split
  • Loading branch information
pablodz authored May 29, 2024
2 parents f65ed39 + 691118c commit b621543
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions examples/alpha/fr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ func main() {
processor, _ := itn.NewLanguage(itn.French)
new_string := processor.Alpha2Digit("un millième", false, true, 3)
println(new_string)
println("-----------------------------------------------------")
println("un 1000ème")
}
11 changes: 8 additions & 3 deletions itn/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"regexp"
"strings"
"unicode/utf8"
)

type Language struct {
Expand Down Expand Up @@ -53,10 +54,13 @@ func (lg *Language) Ord2Card(word string) string {
}

source := ""
runeCount := utf8.RuneCountInString(word)
if plurSuff {
source = word[:len(word)-5]
source = string([]rune(word)[:runeCount-5])
logPrintf(">>>> Ord2Card.3.0.1 %s", source)
} else {
source = word[:len(word)-4]
source = string([]rune(word)[:runeCount-4])
logPrintf(">>>> Ord2Card.3.0.2 %s", source)
}

if source == "cinqu" {
Expand All @@ -65,8 +69,9 @@ func (lg *Language) Ord2Card(word string) string {
source = "neuf"
} else if !containsKey(lg.Numbers, source) {
source = source + "e"
logPrintf(">>>> Ord2Card.3.1 %s", source)
if !containsKey(lg.Numbers, source) {
logPrintf(">>>> Ord2Card.3 %s", source)
logPrintf(">>>> Ord2Card.3.2 %s", source)
return ""
}
}
Expand Down
4 changes: 2 additions & 2 deletions itn/lang_fr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestAlpha2DigitFR(t *testing.T) {
},
{
input: "J'en ai vu au moins trois dans le jardin, et non plus deux.",
output: "J'en ai vu au moins 3 dans le jardin, et non plus 2.",
output: "J'en ai vu au -3 dans le jardin, et non +2.",
},
{
input: "Ne pas confondre un article ou un nom avec un chiffre et inversement : les uns et les autres ; une suite de chiffres : un, deux, trois !",
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestAlpha2DigitFRSignedFalse(t *testing.T) {
tests := []test{
{
input: "J'en ai vu au moins trois dans le jardin, et non plus deux.",
output: "J'en ai vu au moins 3 dans le jardin, et non plus 2.",
output: "J'en ai vu au -3 dans le jardin, et non +2.",
},
}

Expand Down

0 comments on commit b621543

Please sign in to comment.