You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gem implements a PageRank class and a class that allows to perform keyword ranking using the TextRank algorithm. Both were ported from the PHP Implementation by @crodas.
Install
gem install graph-rank
Usage
TextRank
Reference: R. Mihalcea and P. Tarau, “TextRank: Bringing Order into Texts,” in Proceedings of EMNLP 2004. Association for Computational Linguistics, 2004, pp. 404–411.
text='PageRank is a link analysis algorithm, named after Larry ' +
'Page and used by the Google Internet search engine, that assigns ' +
'a numerical weighting to each element of a hyperlinked set of ' +
'documents, such as the World Wide Web, with the purpose of "measuring"' +
'its relative importance within the set.'tr=GraphRank::Keywords.newtr.run(text).inspect
Optionally, you can pass the n-gram size (default = 3), as well as the damping and convergence (see PageRank) to the constructor. Finally, you can set stop words as follows:
tr.stop_words=["word","another","etc"]
PageRank
Reference: Brin, S.; Page, L. (1998). "The anatomy of a large-scale hypertextual Web search engine". Computer Networks and ISDN Systems 30: 107–117.
Optionally, you can pass the damping factor (default = 0.85) and the convergence criterion (default = 0.01) as parameters to the PageRank constructor. Additionally, you can pass in an edge weight parameter to #add and it will be used in the PageRank calculation.
About
Ruby implementation of the PageRank and TextRank algorithms.