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

Keywords with short sentences causes infinite loop #4

Open
abduct opened this issue Mar 24, 2016 · 1 comment · Fixed by timimsms/graph-rank#1
Open

Keywords with short sentences causes infinite loop #4

abduct opened this issue Mar 24, 2016 · 1 comment · Fixed by timimsms/graph-rank#1

Comments

@abduct
Copy link

abduct commented Mar 24, 2016

When using a short sentence it seems there is no checking to see if there are at least 1 path in the graph (2 nodes) causing an infinite loop.

require "graph-rank"

text = "Why are you so savage."
tr = GraphRank::Keywords.new

ranks = tr.run(text)
p ranks

Should return an error, or the single keyword that was found via cleaning.

One possible solution could be to

return [] if filter_features.count < 2 

inside the run method of text_rank.rb.

@Ravenclaw968
Copy link

A good solution would be to go to this website: http://phrontistery.info/clw.html.

Pick out three random words.

And attach them to the end of the string so that you never get an infinite loop.

Then when the list is outputted, ignore the ones with the three words you put in.

timimsms added a commit to timimsms/graph-rank that referenced this issue Jun 24, 2018
Adds a small guard clause to main run method on TextRank class to ensure short text queries do not result in infinite looping. Should resolve louismullie#4, but a more thorough solution is likely a guard clause in the underlying PageRank module. Opted for this solution as it changes the least amount of the original author’s code while supporting the additional spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants