refactoring project structure
This commit is contained in:
50
internal/fetcher/textmanipulation.go
Normal file
50
internal/fetcher/textmanipulation.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user