Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to Python 3 #61

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 15 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
PyTeaser
========

PyTeaser takes any news article and extract a brief summary from it. It's based on the original [Scala](https://github.com/MojoJolo/textteaser) project.
PyTeaser is a Python 3 library that takes any English news article and extracts a brief summary from it. It's based on the original [Scala](https://github.com/MojoJolo/textteaser) project.

```python
>>> from pyteaser import SummarizeUrl
>>> url = 'http://www.huffingtonpost.com/2013/11/22/twitter-forward-secrecy_n_4326599.html'
>>> summary = SummarizeUrl(url)
>>> print(summary)
['"A year and a half ago, Twitter was first served completely over HTTPS," the company said in a blog posting.',
'(Reuters) - Twitter Inc said it has implemented a security technology that makes it harder to spy on its users and called on other Internet firms to do the same, as Web providers look to thwart spying by government intelligence agencies.',
"Twitter's move is the latest response from U.S. Internet firms following disclosures by former spy agency contractor Edward Snowden about widespread, classified U.S. government surveillance programs.",
'"Since then, it has become clearer and clearer how important that step was to protecting our users\' privacy."',
'Facebook Inc, Google Inc, Microsoft Corp and Yahoo Inc have publicly complained that the government does not let them disclose data collection efforts.']
```

Summaries are created by ranking sentences in a news article according to how relevant they are to the entire text. The top 5 sentences are used to form a "summary". Each sentence is ranked by using four criteria:

Expand All @@ -12,43 +23,11 @@ Summaries are created by ranking sentences in a news article according to how re
- Length of the sentence


# Installation:
Requires Python 2.7. (Need Collections.Counter)
```
sudo pip install pyteaser
```

These dependency packages will be automatically installed:
```
Pillow
lxml
cssselect
jieba
beautifulsoup
```
Note: if you're installing on Windows, you have to install one of the dependency package lxml manually using:

```
easy_install lxml==2.3.3
```

More information about this issue here: https://github.com/xiaoxu193/PyTeaser/issues/17


# Usage:
## sample command:
```Python
>>> from pyteaser import SummarizeUrl
>>> url = 'http://www.huffingtonpost.com/2013/11/22/twitter-forward-secrecy_n_4326599.html'
>>> summaries = SummarizeUrl(url)
>>> print summaries
### Installation

```

## output
pip install pyteaser
```
["Twitter\'s move is the latest response from U.S. Internet firms following disclosures by former spy agency contractor Edward Snowden about widespread, classified U.S. government surveillance programs.", "\\"Since then, it has become clearer and clearer how important that step was to protecting our users\' privacy.\\"", "The online messaging service, which began scrambling communications in 2011 using traditional HTTPS encryption, said on Friday it has added an advanced layer of protection for HTTPS known as \\"forward secrecy.\\"", "\\"A year and a half ago, Twitter was first served completely over HTTPS,\\" the company said in a blog posting.", " \\"I\'m glad this is the direction the industry is taking.\\" \\n\\n(Reporting by Jim Finkle; editing by Andrew Hay)"]

```

you can use Summarize(title, text) directly if you already have the text and the title. Otherwise you must install Python Goose to extract text from url.
PyTeaser relies on [goose3](https://github.com/goose3/goose3) for extracting the article body and title from webpages. You can also use `Summarize(title, text)` directly if you already have the title and article text (both should be strings).
9 changes: 0 additions & 9 deletions demo.py

This file was deleted.

202 changes: 0 additions & 202 deletions goose/LICENSE.txt

This file was deleted.

Loading