Python Newspaper3k未返回任何摘要

Python Newspaper3k未返回任何摘要,python,null,summary,article,Python,Null,Summary,Article,我一直在使用Newspaper3k从本地存储的html文章中总结和生成关键字。虽然我可以成功生成关键字,但不能生成摘要。 返回的摘要始终为空 下面是我正在使用的代码 html = '''<div class="col-lg-11">\n <div class="entry-content e-content">\n <div class="img-right caption" style="width:300px"> <img a

我一直在使用Newspaper3k从本地存储的html文章中总结和生成关键字。虽然我可以成功生成关键字,但不能生成摘要。 返回的摘要始终为空

下面是我正在使用的代码

html = '''<div class="col-lg-11">\n
    <div class="entry-content e-content">\n
        <div class="img-right caption" style="width:300px"> <img alt="Plusnet" width="300" height="200" data-src="//dwkujuq9vpuly.cloudfront.net/news/wp-content/uploads/2011/01/plusnet-192701.jpg" data-sizes="auto" class="lazyload" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==">
            <noscript><img src="//dwkujuq9vpuly.cloudfront.net/news/wp-content/uploads/2011/01/plusnet-192701.jpg" alt="Plusnet" width="300" height="200"></noscript> \n
            <p>Plusnet offers broadband and home phone deals</p>\n</div>\n
        <p><strong>The Advertising Standards Authority (ASA) has upheld a complaint against PlusNet, accusing it of using misleading adverts on buses.</strong></p>\n
        <p>The ASA ruled that the BT-owned broadband service provider had misled customers into believing that they could sign up to a broadband package for £6.49 a month.</p>\n
        <p>The reality, the ASA said, was that the advertised package would cost some potential customers £12.99 a month, if they lived outside PlusNet’s low-cost area.</p>\n
        <p>It went onto add that even though PlusNet warned that the headlined price was not available to everyone, it did so in small type face on the bus advertisements, which were hard to read.</p>\n
        <p>Handing out its ruling the ASA said: ‘Small print should be clearly visible to a normally sighted person reading the marketing communication once from a reasonable distance and at a reasonable speed.</p>\n
        <p>‘We considered that the poster should have made clear that the quoted price of £6.49 for broadband was not available to all. Because the small print explaining that was illegible, we concluded that the poster was misleading.</p>\n
        <p>PlusNet was told to ensure that its smallprint on future ads were legible.</p>\n
        <h2>Which? responds</h2>\n
        <p>Ceri Stanaway, Which? broadband expert, said: ‘Its very frustrating to see a great broadband offer only to discover that you can’t get it because of where you live.</p>\n
        <p>‘Even though the PlusNet deal is available to 80% of UK households, PlusNet should have made the restrictions clearer for the 20% of households that can’t get it.</p>\n
        <p>She added: ‘Clearly, more work needs to be done by broadband providers, regulators and government to address the broadband digital divide.</p>\n
        <p><a href="/news/2011/01/cheaper-broadband-deals-for-rural-areas-242623/" title="">Cheaper broadband deals for rural areas</a></p>\n
        <p>To learn more about broadband, take a look at our Which? guide</p>\n
        <div>\n
            <h2>How to follow the latest Which? Tech news</h2>\n
            <p>Are you a <strong>Twitter</strong> user? Follow <a href="https://twitter.com/whichtech" title="" shape="rect">WhichTech on Twitter</a> for regular tech tweets.</p>\n
            <p>Prefer <strong>RSS</strong>? Don’t miss a thing with the <a href="https://www.which.co.uk/feeds/technology.xml" title="" shape="rect">Which? tech RSS feed</a>.\xa0</p>\n
            <p>For just the main headlines in <strong>newsletter</strong> form, sign-up to our weekly Which?\xa0tech email.</p>\n
            <p><a href="http://blogs.which.co.uk/technology/apple/apple-ipad-2-3g-data-plans-compared/" title="" shape="rect">Apple iPad 2 3G data plans compared</a> –\xa0find the best 3G plan for your iPad
                <br><a href="http://blogs.which.co.uk/technology/tablets-2/best-android-tablets-round-up/" title="" shape="rect">Best Android tablets round-up</a> – we look at the best iPad alternatives around
                <br><a href="https://www.which.co.uk/reviews/laptops/article/best-cheap-laptops-for-under-500" title="" shape="rect">Best cheap laptops for under £500</a> – find the best laptop deals</p>\n</div>\n </div>\n\n
    <footer class="entry-footer">\n\n \n
        <p class="entry-categories p-category">Categories:\xa0<a href="https://www.which.co.uk/news/uncategorised/" rel="category tag">Uncategorised</a></p>\n \n \n </footer>\n\n
    <div class="share share-mobile hidden-lg-up">\n <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.which.co.uk%2Fnews%2F2011%2F01%2Fasa-raps-plusnet-243477%2F" class="share__facebook" target="_blank" title="Share ASA raps PlusNet on Facebook" data-mobileurl="https://m.facebook.com/sharer.php?u=https%3A%2F%2Fwww.which.co.uk%2Fnews%2F2011%2F01%2Fasa-raps-plusnet-243477%2F">\n\n    <span class="sr-only">Share on Facebook</span>\n  </a>\n\n <a href="https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.which.co.uk%2Fnews%2F2011%2F01%2Fasa-raps-plusnet-243477%2F&amp;text=ASA%20raps%20PlusNet" class="share__twitter" target="_blank" title="Share ASA raps PlusNet on Twitter" data-mobileurl="https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.which.co.uk%2Fnews%2F2011%2F01%2Fasa-raps-plusnet-243477%2F&amp;text=ASA raps PlusNet">\n\n    <span class="sr-only">Share on Twitter</span>\n  </a>\n\n <a href="mailto:?subject=ASA%20raps%20PlusNet&amp;body=The%20Advertising%20Standards%20Authority%20(ASA)%20has%20upheld%20a%20complaint%20against%20PlusNet,%20accusing%20it%20of%20using%20misleading%20adverts%20on%20buses.%0D%0A%0D%0Ahttps%3A%2F%2Fwww.which.co.uk%2Fnews%2F2011%2F01%2Fasa-raps-plusnet-243477%2F" title="Share ASA raps PlusNet by email" class="share__email">\n\n    <span class="sr-only">Share by email</span>\n  </a>\n</div>\n </div>
    </html>'''


article.set_html(html)
article.parse()
article.nlp()
article.keywords
article.summary






html='''''\n
\n
\n
Plusnet提供宽带和家庭电话交易

\n\n 广告标准管理局(ASA)支持对PlusNet的投诉,指控其在公交车上使用误导性广告。

\n ASA裁定,这家英国电信旗下的宽带服务提供商误导了客户,使他们相信他们可以以每月6.49英镑的价格签订宽带套餐。

\n ASA表示,现实情况是,如果一些潜在客户居住在PlusNet的低成本区域之外,则广告套餐每月将花费12.99英镑。

\n 它还补充说,尽管PlusNet警告说,标题价格并非人人都可以获得,但它还是在公交车广告上用小字字体写的,很难阅读。

\n ASA在发布裁决时说:“正常视力的人在合理的距离和速度下阅读一次营销宣传时,小字应该清晰可见。

\n “我们认为,海报应该清楚地表明,宽带6.49英镑的报价并非所有人都能获得。因为解释这一点的小字字迹难以辨认,我们得出结论认为海报具有误导性。

\n PlusNet被告知要确保其未来广告上的小字体清晰可辨。

\n 哪个?响应\n Ceri Stanaway,哪个?宽带专家说:“看到一个很好的宽带服务却发现因为你住的地方而买不到它,这让人非常沮丧。

\n “尽管PlusNet协议适用于80%的英国家庭,但PlusNet应该为20%无法获得该协议的家庭明确限制。

\n 她补充道:“显然,宽带提供商、监管机构和政府需要做更多的工作来解决宽带数字鸿沟问题。

\n

\n 要了解更多有关宽带的信息,请查看我们的网站?指南

\n \n 如何跟踪最新的哪个?技术新闻\n 你是推特用户吗?关注常规技术推文。

\n 喜欢RSS吗?不要错过任何东西。\xa0

\n 有关时事通讯表单中的主要标题,请注册我们的每周Which?\xa0tech电子邮件。

\n –\xa0为您的iPad找到最佳3G计划
–我们关注周围最好的iPad替代品
–找到最好的笔记本电脑交易

\n\n\n \n\n\n

类别:\xa0

\n\n\n\n \n\n\n\n\n\n\n\n ''' article.set_html(html) 第条解析() 第条nlp() 文章.关键词 第1条概述
您是否启动了nltk?nltk处理摘要

  • 将此行添加到代码顶部: 导入nltk

  • 在“article.nlp()”之前添加此行: nltk.download('punkt')#一次下载句子标记器