lexrank
lexrank copied to clipboard
ImportError: cannot import name 'degree_centrality_scores' from 'lexrank'
Got this issue on MacBook Pro. Python version: 3.7.4
Reproducibility:
python3 -m venv env
source env/bin/activate
pip3 install lexrank
python3 -c "from lexrank import degree_centrality_scores"
Currently, the degree_centrality_scores
function's code is only on dev. So the easiest would be to just clone the repository somewhere near your own code, checkout dev, and just import the function like that:
import sys
sys.path.append("../../lexrank/")
from lexrank.lexrank import degree_centrality_score
Currently, the
degree_centrality_scores
function's code is only on dev. So the easiest would be to just clone the repository somewhere near your own code, checkout dev, and just import the function like that:import sys sys.path.append("../../lexrank/") from lexrank.lexrank import degree_centrality_score
Just for anyone who is here with the same problem
The import is
from lexrank.lexrank import degree_centrality_scores
with an "s"
Also, in the README there is a typo. Change every instance of "thershold" for "threshold"
I want to install the dev branch of lexrank from requirements.txt. https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch suggests I can use
pip install -U git+https://github.com/crabcamp/lexrank.git@dev
but this results in installing lexrank-0.1.0
(a tag, not the dev branch). Any other suggestions (as the one suggested here fails pre-commit
hooks).
You can point to a specific commit e.g. git+https://github.com/crabcamp/lexrank.git@07bdd1579c408cf73cc822da303734d0a70cf3f7
but the current dev branch seems to be in a broken state where you cannot import lexrank at all.
@hansharhoff Thank you for the response. I tried adding that to requirements.txt and get the following:
(rato-processing) » pip install -r requirements.txt
Collecting en-core-web-sm@ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz (13.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.9/13.9 MB 11.2 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting lexrank@ git+https://github.com/crabcamp/lexrank.git@07bdd1579c408cf73cc822da303734d0a70cf3f7
Cloning https://github.com/crabcamp/lexrank.git (to revision 07bdd1579c408cf73cc822da303734d0a70cf3f7) to /tmp/pip-install-xa9e1of4/lexrank_5f66269c2deb4851b465f2dcf499c643
Running command git clone --filter=blob:none --quiet https://github.com/crabcamp/lexrank.git /tmp/pip-install-xa9e1of4/lexrank_5f66269c2deb4851b465f2dcf499c643
Running command git rev-parse -q --verify 'sha^07bdd1579c408cf73cc822da303734d0a70cf3f7'
Running command git fetch -q https://github.com/crabcamp/lexrank.git 07bdd1579c408cf73cc822da303734d0a70cf3f7
Resolved https://github.com/crabcamp/lexrank.git to commit 07bdd1579c408cf73cc822da303734d0a70cf3f7
Preparing metadata (setup.py) ... done
...
Building wheels for collected packages: lexrank
Building wheel for lexrank (setup.py) ... done
Created wheel for lexrank: filename=lexrank-0.1.0-py3-none-any.whl size=69896 sha256=35ab5ddf261aaefa33f8051eb3f37c0eadbced9639bdbf1d658f609cc486188c
Stored in directory: /home/fen/.cache/pip/wheels/17/44/a6/7f5d731bb4dab8c972e429a5edf728ad82830eb6cb4f4c4975
Successfully built lexrank
Installing collected packages: lexrank
Successfully installed lexrank-0.1.0
which, of course, is not the version I want. Is it because "the current dev branch seems to be in a broken state where you cannot import lexrank at all"? Can anything be done (without access to pushing changes)? I suppose I could fork it...
I endend up using this example which has copied the relevant code to a single file:
https://github.com/UKPLab/sentence-transformers/tree/master/examples/applications/text-summarization
@hansharhoff thank you - that worked!
Works perfectly thanks @hansharhoff
I am using the bert-extractive-summarizer package. However, sometimes I get +/-inf values as the centrality score. I dug a little deeper and found that the eigenvalues are coming as +/-inf. And this is probably caused by near-zero cosine similarity scores. If I add a constant such as 1.1 with all the cosine similarity scores, I do not get the +/-inf values anymore. My question is - does adding a particular constant to the cosine similarity score, in this case, bias the centrality score? I just wanted to know if there is any better solution in this particular case. Thank you in advance.
@hansharhoff thank you!