Repository: piskvorky/gensim

Issue:
"Pattern library is not installed" ... but it is (perhaps because it is called pattern3)
<!--
**IMPORTANT**:

- Use the [Gensim mailing list](https://groups.google.com/forum/#!forum/gensim) to ask general or usage questions. Github issues are only for bug reports.
- Check [Recipes&FAQ](https://github.com/RaRe-Technologies/gensim/wiki/Recipes-&-FAQ) first for common answers.

Github bug reports that do not include relevant information and context will be closed without an answer. Thanks!
-->

#### Problem description

I am trying to do a gensim tutorial project. I am attempting to lemmatize and getting this error:
ImportError: Pattern library is not installed. Pattern library is needed in order to use lemmatize function

After searching the web, I installed pattern3, I still get the same error. I tried to do 'import pattern3 as pattern' but that doesn't help. Obviously I'm on python 3 (3.6)

#### Steps/code/corpus to reproduce

 import gensim
 from gensim.utils import simple_preprocess, lemmatize
 import pattern3

lemmatize("hello")

#### Versions

Please provide the output of:

```python
import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import gensim; print("gensim", gensim.__version__)
from gensim.models import word2vec;print("FAST_VERSION", word2vec.FAST_VERSION)
```

Darwin-15.6.0-x86_64-i386-64bit
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.16.4
SciPy 1.2.1
gensim 3.7.3
FAST_VERSION 1

#### Additional info

`from pattern3.web import Twitter`
this works fine

`from pattern.web import Twitter`
this does not (even after I do `import pattern3 as pattern`)
"Pattern library is not installed" ... but it is (perhaps because it is called pattern3)
<!--
**IMPORTANT**:

- Use the [Gensim mailing list](https://groups.google.com/forum/#!forum/gensim) to ask general or usage questions. Github issues are only for bug reports.
- Check [Recipes&FAQ](https://github.com/RaRe-Technologies/gensim/wiki/Recipes-&-FAQ) first for common answers.

Github bug reports that do not include relevant information and context will be closed without an answer. Thanks!
-->

#### Problem description

I am trying to do a gensim tutorial project. I am attempting to lemmatize and getting this error:
ImportError: Pattern library is not installed. Pattern library is needed in order to use lemmatize function

After searching the web, I installed pattern3, I still get the same error. I tried to do 'import pattern3 as pattern' but that doesn't help. Obviously I'm on python 3 (3.6)

#### Steps/code/corpus to reproduce

 import gensim
 from gensim.utils import simple_preprocess, lemmatize
 import pattern3

lemmatize("hello")

#### Versions

Please provide the output of:

```python
import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import gensim; print("gensim", gensim.__version__)
from gensim.models import word2vec;print("FAST_VERSION", word2vec.FAST_VERSION)
```

Darwin-15.6.0-x86_64-i386-64bit
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.16.4
SciPy 1.2.1
gensim 3.7.3
FAST_VERSION 1

#### Additional info

`from pattern3.web import Twitter`
this works fine

`from pattern.web import Twitter`
this does not (even after I do `import pattern3 as pattern`)


Discussion:
Does `pattern` support Python 3 now?

If so, we could perhaps upgrade that (optional) dependency in Gensim.

@falconair Can you open a PR with the `pattern` migration? Assuming it offers similar functionality as the old one – it has to be 100% clear what the differences and implications are of migrating, before we do that.
From pattern's [Readme](https://github.com/clips/pattern/blob/master/README.md) it looks like it supports Python 3.

I'll try to take this one.
I think these may be the same essential package:

- [pattern3](https://pypi.org/project/pattern3/)
- [Pattern](https://pypi.org/project/Pattern/) (not the upper-case P, it matters to PyPI)

and gensim is only looking for one of them.
Does `pattern` support Python 3 now?

If so, we could perhaps upgrade that (optional) dependency in Gensim.

@falconair Can you open a PR with the `pattern` migration? Assuming it offers similar functionality as the old one – it has to be 100% clear what the differences and implications are of migrating, before we do that.
From pattern's [Readme](https://github.com/clips/pattern/blob/master/README.md) it looks like it supports Python 3.

I'll try to take this one.
I think these may be the same essential package:

- [pattern3](https://pypi.org/project/pattern3/)
- [Pattern](https://pypi.org/project/Pattern/) (not the upper-case P, it matters to PyPI)

and gensim is only looking for one of them.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -276,13 +276,14 @@ def finalize_options(self):
     ])
 
 if (3, 0) < sys.version_info < (3, 7):
-    linux_testenv.extend(['nmslib'])    
-    
+    linux_testenv.extend(['nmslib'])
+
 docs_testenv = linux_testenv + distributed_env + [
     'sphinx',
     'sphinxcontrib-napoleon',
     'plotly',
-    'pattern <= 2.6',
+# Pattern's version is specified to install Pattern 3.6, which adds python3 support
+    'Pattern >= 3.6',
     'sphinxcontrib.programoutput',
 ]
 #
@@ -360,7 +361,7 @@ def finalize_options(self):
 
     url='http://radimrehurek.com/gensim',
     download_url='http://pypi.python.org/pypi/gensim',
-    
+
     license='LGPLv2.1',
 
     keywords='Singular Value Decomposition, SVD, Latent Semantic Indexing, '


Test patch: