Is biasedtextrank
implemented?
#244
Replies: 4 comments
-
Hi @Ayenem , Thanks for checking out Here"s how you can use biasedtextrank: import spacy
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("biasedtextrank")
text = "your text here"
focus = "your focus here"
doc = nlp(text)
print(doc._.phrases) # gives you default phrases
doc._.textrank.change_focus(focus,bias=10.0, default_bias=0.0) # provide focus, adjust bias to achieve desired disparity between focus vs rest
print(doc._.phrases) # gives you ranked phrases as per focus |
Beta Was this translation helpful? Give feedback.
-
That worked, thank you! If I understand correctly, 10.0 is the highest |
Beta Was this translation helpful? Give feedback.
-
Biased text rank is special case of personalized textrank where we add more weight to the focus nodes. In base textrank each node has weight one and then those weight go through normalization(1/sum of all weights) so that they are in range[0,1].
In the example each focus node will get the weight of 10 and non focus nodes will get the weight 0. Please refer to this PR for detailed discussion. |
Beta Was this translation helpful? Give feedback.
-
So I'm already doing what I intended by replicating the Also, do you know if there has been progress on the implementation of an optional input KG for biased textrank? @ceteri |
Beta Was this translation helpful? Give feedback.
-
pytextrank/pytextrank/base.py
Line 305 in 9ab6450
self.focus_tokens
is initialized to an empty set but I don't see where it is parameterized?e.g.
At what point can I inform the model of the
focus
?Beta Was this translation helpful? Give feedback.
All reactions