Files
psalms/textmanipulation.go
2026-03-24 18:39:59 +01:00

51 lines
1.1 KiB
Go

package main
import(
"log"
"regexp"
"strings"
"unicode"
"unicode/utf8"
)
func stripAlternativeVersification(rawChapter chapter) chapter{
regExp:=regexp.MustCompile(`\(\d+:\d+\)`)
var treatedChapter chapter
for _, verse := range rawChapter.verses{
modifiedVerse := string(regExp.ReplaceAll([]byte(verse), []byte("")))
log.Printf("%v\n", modifiedVerse)
treatedChapter.verses = append(treatedChapter.verses, modifiedVerse)
}
return treatedChapter
}
func splitInPart(verse string, properName map[string]struct{})(){
currentPart := ""
words := strings.Split(strings.TrimSpace(verse), " ")
wordsCount := len(words)
isTreated := false
for i :=0 ; i < wordsCount ; i++{
word := words[i]
r, _ := utf8.DecodeRuneInString(word)
trimedWord := strings.TrimRight(word, ".,")
_, isProperName := properName[trimedWord]
if i != 0 && unicode.IsUpper(r) && !isProperName{
log.Printf("%s", currentPart)
currentPart = word
isTreated = true
}else{
currentPart += " " + word
isTreated = false
}
}
if !isTreated {
log.Printf("%s", currentPart)
}
}