Skip to content
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

.DS_Store

takahe/takahe.pyc
*.pyc
__pycache__
*.dot
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@ A keyphrase-based reranking method can be applied to generate more informative c

## Dependancies

As of today, takahe is built for Python 2.
As of today, takahe is built for Python 3.7.

You may need to install the following libraries :

- [networkx](http://networkx.github.io/) (installation guide is available [here](http://networkx.github.io/documentation/latest/install.html))
- [networkx=1.11](http://networkx.github.io/) (installation guide is available [here](http://networkx.github.io/documentation/latest/install.html))
- [graphviz](http://www.graphviz.org/) and graphviz-dev
- [pygraphviz](http://pygraphviz.github.io/documentation/latest/install.html)
- [pydotplus](https://pypi.org/project/pydotplus/)



## Example
A typical usage of this module is:

import takahe

# Create a word graph from the set of sentences with parameters :
# - minimal number of words in the compression : 6
# - language of the input sentences : en (english)
# - POS tag for punctuation marks : PUNCT
compresser = takahe.word_graph( sentences,
nb_words = 6,
lang = 'en',
compresser = takahe.word_graph( sentences,
nb_words = 6,
lang = 'en',
punct_tag = "PUNCT" )

# Get the 50 best paths
Expand All @@ -52,13 +53,13 @@ A typical usage of this module is:

# 2. Rerank compressions by keyphrases (Boudin and Morin's method)
reranker = takahe.keyphrase_reranker( sentences,
candidates,
candidates,
lang = 'en' )

reranked_candidates = reranker.rerank_nbest_compressions()

# Loop over the best reranked candidates
for score, path in reranked_candidates:

# Print the best reranked candidates
print round(score, 3), ' '.join([u[0] for u in path])
20 changes: 10 additions & 10 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import takahe
from takahe import takahe


################################################################################
Expand All @@ -10,7 +10,7 @@
Monday/NNP ./PUNCT", "Hillary/NNP Clinton/NNP wanted/VBD to/TO visit/VB China/NNP \
last/JJ month/NN but/CC postponed/VBD her/PRP$ plans/NNS till/IN Monday/NNP \
last/JJ week/NN ./PUNCT", "Hillary/NNP Clinton/NNP paid/VBD a/DT visit/NN to/TO \
the/DT People/NNP Republic/NNP of/IN China/NNP on/IN Monday/NNP ./PUNCT",
the/DT People/NNP Republic/NNP of/IN China/NNP on/IN Monday/NNP ./PUNCT",
"Last/JJ week/NN the/DT Secretary/NNP of/IN State/NNP Ms./NNP Clinton/NNP \
visited/VBD Chinese/JJ officials/NNS ./PUNCT"]
################################################################################
Expand All @@ -19,9 +19,9 @@
# - minimal number of words in the compression : 6
# - language of the input sentences : en (english)
# - POS tag for punctuation marks : PUNCT
compresser = takahe.word_graph( sentences,
nb_words = 6,
lang = 'en',
compresser = takahe.word_graph( sentences,
nb_words = 6,
lang = 'en',
punct_tag = "PUNCT" )

# Get the 50 best paths
Expand All @@ -34,20 +34,20 @@
normalized_score = cummulative_score / len(path)

# Print normalized score and compression
print round(normalized_score, 3), ' '.join([u[0] for u in path])
print(round(normalized_score, 3), ' '.join([u[0] for u in path]))

# Write the word graph in the dot format
compresser.write_dot('test.dot')

# 2. Rerank compressions by keyphrases (Boudin and Morin's method)
reranker = takahe.keyphrase_reranker( sentences,
candidates,
reranker = takahe.keyphrase_reranker( sentences,
candidates,
lang = 'en' )

reranked_candidates = reranker.rerank_nbest_compressions()

# Loop over the best reranked candidates
for score, path in reranked_candidates:

# Print the best reranked candidates
print round(score, 3), ' '.join([u[0] for u in path])
print(round(score, 3), ' '.join([u[0] for u in path]))
Binary file removed takahe/__init__.pyc
Binary file not shown.
Loading