Skip to content

Commit

Permalink
Test python 2, include various compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Sep 23, 2018
1 parent d8e0f4e commit 0a31f93
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python

python:
# - "2.7"
- "2.7"
- "3.4"
- "3.5"
- "3.6"
Expand Down
3 changes: 3 additions & 0 deletions quantulum3/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
:mod:`Quantulum` classes.
"""

# Python 2 compatibility
from __future__ import unicode_literals

# Dependencies
import inflect
import num2words
Expand Down
2 changes: 1 addition & 1 deletion quantulum3/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:mod:`Quantulum` classifier functions.
"""

# Python 2 compatability
# Python 2 compatibility
from __future__ import unicode_literals

# Standard library
Expand Down
8 changes: 3 additions & 5 deletions quantulum3/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
:mod:`Quantulum` unit and entity loading functions.
"""

# Python 2 compatability
# Python 2 compatibility
from __future__ import unicode_literals

from io import open

# Standard library
import os
import json
from collections import defaultdict
import re
from io import open

# Dependencies
import inflect
from unidecode import unidecode

# Quantulum
from . import classes as c
Expand Down Expand Up @@ -227,7 +225,7 @@ def load_unit(unit, names, unit_symbols, unit_symbols_lower, surfaces, lowers,
for num, i in enumerate(split)
])
else:
plural = PLURALS.plural(unidecode(surface))
plural = PLURALS.plural(surface)
if plural != surface:
surfaces[plural].append(obj)
lowers[plural.lower()].append(obj)
Expand Down
3 changes: 3 additions & 0 deletions quantulum3/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
:mod:`Quantulum` parser.
"""

# Python 2 compatability
from __future__ import unicode_literals

# Standard library
import re
import logging
Expand Down
2 changes: 1 addition & 1 deletion quantulum3/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:mod:`Quantulum` regex functions.
"""

# Python 2 compatability
# Python 2 compatibility
from __future__ import unicode_literals

# Standard library
Expand Down
3 changes: 3 additions & 0 deletions quantulum3/tests/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
:mod:`Quantulum` tests.
"""

# Python 2 compatibility
from __future__ import unicode_literals

# Standard library
import os
import json
Expand Down
3 changes: 3 additions & 0 deletions quantulum3/tests/test_no_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
:mod:`Quantulum` tests.
"""

# Python 2 compatibility
from __future__ import unicode_literals

# Standard library
import os
import unittest
Expand Down
4 changes: 4 additions & 0 deletions quantulum3/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
:mod:`Quantulum` tests.
"""

# Python 2 compatibility
from __future__ import unicode_literals

# Standard library
import os
import re
import json
import unittest
from io import open

# Dependencies
try:
Expand Down
1 change: 1 addition & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import json
from io import open

from quantulum3 import load
'''
Expand Down
3 changes: 0 additions & 3 deletions scripts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# -*- coding: utf-8 -*-
''' Train the disambiguator '''

import sys
import os

from quantulum3.classifier import train_classifier

train_classifier(download=False, store=True)

0 comments on commit 0a31f93

Please sign in to comment.