
Pytextrank – A pure Python implementation of TextRank - rch
https://github.com/ceteri/pytextrank
======
mikkom
I don't find any information on what version of Python this works with, any
pointers? 2.X 3?

How is this different from all the other textrank implementation? Is this more
complete?

[https://github.com/summanlp/textrank](https://github.com/summanlp/textrank)

[https://github.com/davidadamojr/TextRank](https://github.com/davidadamojr/TextRank)

[https://github.com/galsang/PyTextRank](https://github.com/galsang/PyTextRank)

rant: I hate how complex the python ecosystem is, there are different versions
for language, different packaging systems (this project uses both conda and
pip), sometimes you need to install stuff even with OS package manager or
install packages from the source. Something really needs to be done for this
mess.

~~~
mhuffman
Pro-tip: If you are curious and they don't mention version support, search the
repo for "print" statements to help you distinguish.

~~~
samuel
Following that advice, it seems that's py3 compatible only. Print statements
are function calls without having imported from future.

~~~
sixhobbits
it only works the other way -- 2.7+ allows both

    
    
        print("hello")
        print "hello"
    

while 3+ allows only

    
    
        print("hello")

~~~
dr_zoidberg
In Py2.7 you need:

    
    
        from __future__ import print_function
    

to get the print("hello") behaviour.

~~~
geoelectric
No, because the () just ends up being a no-op as grouping parentheses in the
expression in Python 2.

What the import from __future__ does is make the original non-parens version
illegal syntax in Python 2. You _have_ to treat it like a function call with
that import.

~~~
BerislavLopac
There is another, less obvious difference: in Python 2, if you print multiple
items in parentheses, you're actually printing a tuple:

    
    
        >>> print "foo", 1, 2, "bar", "baz"
        foo 1 2 bar baz
        >>> print("foo", 1, 2, "bar", "baz")
        ('foo', 1, 2, 'bar', 'baz')
        >>> from __future__ import print_function
        >>> print("foo", 1, 2, "bar", "baz")
        foo 1 2 bar baz

~~~
geoelectric
True, that, behavior-wise. It's the comma that actually defines the tuple,
though, hence (1) being different than (1,) and x = 1,2 assigning (1,2).

In the particular case of a print statement, the grouping parens disambiguate
between the comma meaning multiple args and a single arg that's a tuple, once
Python 2 implicitly wraps the entire right side with function calling parens.

In the end it's really a form of operator precedence. The from __future__
version behaves differently only because the function calling parens are now
explicit and so tuple grouping parens must be added too if desired.

