Ejemplo n.º 1
0
def test_link_density():
    """Test that we get a link density"""
    doc = document_fromstring(load_article('ars.001.html'))
    for node in doc.iter('p', 'td', 'pre'):
        density = get_link_density(node)

        # the density must be between 0, 1
        assert density >= 0.0 and density <= 1.0
Ejemplo n.º 2
0
def test_link_density():
    """Test that we get a link density"""
    doc = document_fromstring(load_article('ars.001.html'))
    for node in doc.iter('p', 'td', 'pre'):
        density = get_link_density(node)

        # the density must be between 0, 1
        assert density >= 0.0 and density <= 1.0
Ejemplo n.º 3
0
    def test_link_density(self):
        """Test that we get a link density"""
        doc = document_fromstring(load_article('ars/ars.001.html'))
        for node in doc.getiterator():
            if node.tag in ['p', 'td', 'pre']:
                density = get_link_density(node)

                # the density must be between 0, 1
                self.assertTrue(density >= 0.0 and density <= 1.0)
Ejemplo n.º 4
0
    def test_link_density(self):
        """Test that we get a link density"""
        doc = document_fromstring(load_article('ars/ars.001.html'))
        for node in doc.getiterator():
            if node.tag in ['p', 'td', 'pre']:
                density = get_link_density(node)

                # the density must be between 0, 1
                self.assertTrue(density >= 0.0 and density <= 1.0)
Ejemplo n.º 5
0
 def test_small_doc_no_links(self):
     doc = Article(load_snippet('document_min.html'))
     assert 0 == get_link_density(doc._readable), "Still no link density"
Ejemplo n.º 6
0
def test_empty_node():
    """An empty node doesn't have much of a link density"""
    doc = Article("<div></div>")

    assert get_link_density(doc.readable_dom) == 0.0
Ejemplo n.º 7
0
def test_small_doc_no_links():
    doc = Article(load_snippet('document_min.html'))

    assert get_link_density(doc.readable_dom) == 0.0
Ejemplo n.º 8
0
 def test_empty_node(self):
     """An empty node doesn't have much of a link density"""
     doc = Article("<div></div>")
     self.assertEqual(get_link_density(doc.readable_dom), 0.0)
Ejemplo n.º 9
0
def test_several_links():
    """This doc has a 3 links with the majority of content."""
    doc = Article(load_snippet('document_absolute_url.html'))

    assert get_link_density(doc.readable_dom) == 22 / 37
Ejemplo n.º 10
0
 def test_small_doc_no_links(self):
     doc = Article(load_snippet('document_min.html'))
     assert 0 == get_link_density(doc._readable), "Still no link density"
Ejemplo n.º 11
0
 def test_several_links(self):
     """This doc has a 3 links with the majority of content."""
     doc = Article(load_snippet('document_absolute_url.html'))
     self.assertAlmostEqual(get_link_density(doc.readable_dom), 22/37)
Ejemplo n.º 12
0
 def test_empty_node(self):
     """An empty node doesn't have much of a link density"""
     empty_div = u"<div></div>"
     doc = Article(empty_div)
     assert 0 == get_link_density(doc._readable), "Link density is nadda"
Ejemplo n.º 13
0
def test_several_links():
    """This doc has a 3 links with the majority of content."""
    doc = Article(load_snippet('document_absolute_url.html'))

    assert get_link_density(doc.readable_dom) == 22/37
Ejemplo n.º 14
0
 def test_empty_node(self):
     """An empty node doesn't have much of a link density"""
     doc = Article("<div></div>")
     self.assertEqual(get_link_density(doc.readable_dom), 0.0)
Ejemplo n.º 15
0
 def test_several_links(self):
     """This doc has a 3 links with the majority of content."""
     doc = Article(load_snippet('document_absolute_url.html'))
     self.assertAlmostEqual(get_link_density(doc.readable_dom), 22 / 37)
Ejemplo n.º 16
0
 def test_small_doc_no_links(self):
     doc = Article(load_snippet('document_min.html'))
     self.assertEqual(get_link_density(doc.readable_dom), 0.0)
Ejemplo n.º 17
0
def test_small_doc_no_links():
    doc = Article(load_snippet('document_min.html'))

    assert get_link_density(doc.readable_dom) == 0.0
Ejemplo n.º 18
0
def test_empty_node():
    """An empty node doesn't have much of a link density"""
    doc = Article("<div></div>")

    assert get_link_density(doc.readable_dom) == 0.0
Ejemplo n.º 19
0
 def test_small_doc_no_links(self):
     doc = Article(load_snippet('document_min.html'))
     self.assertEqual(get_link_density(doc.readable_dom), 0.0)
Ejemplo n.º 20
0
 def test_empty_node(self):
     """An empty node doesn't have much of a link density"""
     empty_div = u"<div></div>"
     doc = Article(empty_div)
     assert 0 == get_link_density(doc._readable), "Link density is nadda"