refactoring with internal

This commit is contained in:
github_username_here
2026-03-04 14:21:24 +01:00
parent 8fdf7c190a
commit 7355158ff9
6 changed files with 88 additions and 70 deletions

View File

@@ -1,6 +1,7 @@
package main
package fetcher
import(
"project.hechon.fr/internal/config"
"log"
"regexp"
"strings"
@@ -8,21 +9,28 @@ import(
"unicode/utf8"
)
func stripAlternativeVersification(rawChapter chapter) chapter{
func StripAlternativeVersification(rawChapter config.Chapter) config.Chapter{
/* a handful of verses have 2 traditions of numbering, the alternative
* rendering appears then between brackets. This is a simple use of
* regexp to get rid of it
*/
regExp:=regexp.MustCompile(`\(\d+:\d+\)`)
var treatedChapter chapter
for _, verse := range rawChapter.verses{
var treatedChapter config.Chapter
for _, verse := range rawChapter.Verses{
modifiedVerse := string(regExp.ReplaceAll([]byte(verse), []byte("")))
log.Printf("%v\n", modifiedVerse)
treatedChapter.verses = append(treatedChapter.verses, modifiedVerse)
treatedChapter.Verses = append(treatedChapter.Verses, modifiedVerse)
}
return treatedChapter
}
func splitInPart(verse string, properName map[string]struct{})(){
func SplitInPart(verse string, properName map[string]struct{})([]string){
var parts []string
currentPart := ""
words := strings.Split(strings.TrimSpace(verse), " ")
wordsCount := len(words)
@@ -34,7 +42,7 @@ func splitInPart(verse string, properName map[string]struct{})(){
trimedWord := strings.TrimRight(word, ".,")
_, isProperName := properName[trimedWord]
if i != 0 && unicode.IsUpper(r) && !isProperName{
log.Printf("%s", currentPart)
parts = append(parts, currentPart)
currentPart = word
isTreated = true
}else{
@@ -44,7 +52,8 @@ func splitInPart(verse string, properName map[string]struct{})(){
}
if !isTreated {
log.Printf("%s", currentPart)
parts = append(parts, currentPart)
}
return parts
}