mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
gofmt -s -w .
This commit is contained in:
parent
614dcc8975
commit
2df2f41516
@ -2,10 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"io"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nkanaev/yarr/src/content/readability"
|
"github.com/nkanaev/yarr/src/content/readability"
|
||||||
|
@ -23,8 +23,7 @@ func TestQuery(t *testing.T) {
|
|||||||
</html>
|
</html>
|
||||||
`))
|
`))
|
||||||
nodes := Query(node, "p")
|
nodes := Query(node, "p")
|
||||||
match := (
|
match := (len(nodes) == 1 &&
|
||||||
len(nodes) == 1 &&
|
|
||||||
nodes[0].Type == html.ElementNode &&
|
nodes[0].Type == html.ElementNode &&
|
||||||
nodes[0].Data == "p")
|
nodes[0].Data == "p")
|
||||||
if !match {
|
if !match {
|
||||||
@ -50,8 +49,7 @@ func TestQueryMulti(t *testing.T) {
|
|||||||
</html>
|
</html>
|
||||||
`))
|
`))
|
||||||
nodes := Query(node, "p , span")
|
nodes := Query(node, "p , span")
|
||||||
match := (
|
match := (len(nodes) == 3 &&
|
||||||
len(nodes) == 3 &&
|
|
||||||
nodes[0].Type == html.ElementNode && nodes[0].Data == "p" &&
|
nodes[0].Type == html.ElementNode && nodes[0].Data == "p" &&
|
||||||
nodes[1].Type == html.ElementNode && nodes[1].Data == "p" &&
|
nodes[1].Type == html.ElementNode && nodes[1].Data == "p" &&
|
||||||
nodes[2].Type == html.ElementNode && nodes[2].Data == "span")
|
nodes[2].Type == html.ElementNode && nodes[2].Data == "span")
|
||||||
|
@ -129,8 +129,7 @@ func removeUnlikelyCandidates(root *html.Node) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklisted := (
|
blacklisted := (blacklistCandidatesRegexp.MatchString(str) ||
|
||||||
blacklistCandidatesRegexp.MatchString(str) ||
|
|
||||||
(unlikelyCandidatesRegexp.MatchString(str) &&
|
(unlikelyCandidatesRegexp.MatchString(str) &&
|
||||||
!okMaybeItsACandidateRegexp.MatchString(str)))
|
!okMaybeItsACandidateRegexp.MatchString(str)))
|
||||||
if blacklisted && node.Parent != nil {
|
if blacklisted && node.Parent != nil {
|
||||||
@ -198,7 +197,7 @@ func getCandidates(root *html.Node) nodeScores {
|
|||||||
// Scale the final candidates score based on link density. Good content
|
// Scale the final candidates score based on link density. Good content
|
||||||
// should have a relatively small link density (5% or less) and be mostly
|
// should have a relatively small link density (5% or less) and be mostly
|
||||||
// unaffected by this operation
|
// unaffected by this operation
|
||||||
for node, _ := range scores {
|
for node := range scores {
|
||||||
scores[node] *= (1 - getLinkDensity(node))
|
scores[node] *= (1 - getLinkDensity(node))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,5 +241,4 @@ func m04_item_podcasturl(tx *sql.Tx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: description -> content
|
// TODO: description -> content
|
||||||
|
Loading…
x
Reference in New Issue
Block a user