fix voor zinnen aan elkaar

This commit is contained in:
Peter Kleiweg
2026-05-29 17:22:10 +02:00
parent ca4e7af8fa
commit 14590570ba
18 changed files with 54 additions and 32 deletions

View File

@@ -161,6 +161,8 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
p(err)
p(resp.Body.Close())
body = u.HtmlFix(body)
s := string(body)
ok := true
i1 := strings.Index(s, `<script type="application/ld+json"`)
@@ -226,22 +228,9 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
// text bevat kopjes zonder punt aan het eind
lines := strings.Split(text, "\n")
for i, line := range lines {
line = u.FixSpace(line)
n := len(line)
if n > 0 {
if strings.ContainsAny(line[n-1:], ".!?") {
continue
}
}
if n > 1 {
s := line[n-2:]
if s == `."` || s == `!"` || s == `?"` {
continue
}
}
lines[i] = line + "."
lines[i] = u.AddEnd(u.FixSpace(line, true))
}
text = strings.Join(lines, "\n") + "\n"
text = strings.Join(lines, "") + "\n"
fp, err := os.Create(filename + ".txt")
p(err)