Repository: nltk/nltk

Issue:
ChrF score failing tests
ChrF score tests are failing with python 3.4 and python 3.5:

```
tox -e py34 nltk/nltk/translate/chrf_score.py

GLOB sdist-make: nltk/setup.py
py34 inst-nodeps: nltk/.tox/dist/nltk-3.2.1.zip
py34 installed: coverage==4.2,nltk==3.2.1,nose==1.3.7,numpy==1.11.2,oauthlib==2.0.0,pyparsing==2.1.10,python-crfsuite==0.8.4,requests==2.12.1,requests-oauthlib==0.7.0,scikit-learn==0.18.1,scipy==0.18.1,six==1.10.0,text-unidecode==1.0,twython==3.4.0
py34 runtests: PYTHONHASHSEED='300012027'
py34 runtests: commands[0] | pip install scipy scikit-learn
Requirement already satisfied: scipy in nltk/.tox/py34/lib/python3.4/site-packages
Requirement already satisfied: scikit-learn in nltk/.tox/py34/lib/python3.4/site-packages
py34 runtests: commands[1] | python runtests.py ../translate/chrf_score.py
.F
======================================================================
FAIL: Doctest: nltk.translate.chrf_score.sentence_chrf
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/doctest.py", line 2187, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for nltk.translate.chrf_score.sentence_chrf
  File "nltk/nltk/translate/chrf_score.py", line 16, in sentence_chrf

----------------------------------------------------------------------
File "nltk/nltk/translate/chrf_score.py", line 58, in nltk.translate.chrf_score.sentence_chrf
Failed example:
    type(ref1), type(hyp1)
Expected:
    (<type 'str'>, <type 'str'>)
Got:
    (<class 'str'>, <class 'str'>)


----------------------------------------------------------------------
Ran 2 tests in 0.013s

FAILED (failures=1)
```

@alvations could you please check?


Discussion:
That is a pesky problem when running tests when types become classes in Python3. Let me find a way to over overcome this. There must be some Python2to3 tricks.

I've very reluctant to do something like:

``` python
type(ref1) == type(hyp1) == str
```

But if there's no clean way to do it, perhaps the above would suffice.

@alvations We could also use `.__class__.__name__`:
```python
>>> ref1.__class__.__name__, hyp1.__class__.__name__
('str', 'str')
```
or
```python
>>> type(ref1).__name__, type(hyp1).__name__
('str', 'str')
```
but I actually think that your solution would be better:
```python
>>> type(ref1) == type(hyp1) == str
True
```
@fievelk thanks for the alternative solutions.

Reluctantly, I think it's cleanest to go with

```python
>>> type(ref1) == type(hyp1) == str
True
```

Resolving patch:
diff --git a/nltk/translate/chrf_score.py b/nltk/translate/chrf_score.py
--- a/nltk/translate/chrf_score.py
+++ b/nltk/translate/chrf_score.py
@@ -55,8 +55,8 @@ def sentence_chrf(reference, hypothesis, min_len=1, max_len=6, beta=3.0):
         ...            'always obeys the commands of the party')
         >>> sentence_chrf(ref1, hyp1) # doctest: +ELLIPSIS
         0.6768...
-        >>> type(ref1), type(hyp1)
-        (<type 'str'>, <type 'str'>)
+        >>> type(ref1) == type(hyp1) == str
+        True
         >>> sentence_chrf(ref1.split(), hyp1.split()) # doctest: +ELLIPSIS
         0.6768...
 


Test patch: