Skip to content

Commit

Permalink
[expand] Removing language requirement in expand since that is now ha…
Browse files Browse the repository at this point in the history
…ndled automatically with the language classifier
  • Loading branch information
albarrentine committed Jan 27, 2016
1 parent 1589b96 commit 957903c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
7 changes: 2 additions & 5 deletions postal/expand.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import _expand
from postal.utils.encoding import safe_decode

DEFAULT_LANGUAGES = ('en',)


def expand_address(address, languages=DEFAULT_LANGUAGES, **kw):
def expand_address(address, languages=None, **kw):
'''
@param address: the address as either Unicode or a UTF-8 encoded string
@param languages: a tuple or list of ISO language code strings (e.g. "en", "fr", "de", etc.)
to use in expansion. Default is English. Until automatic language classification
is ready in libpostal, this parameter is required.
to use in expansion.
'''
address = safe_decode(address, 'utf-8')
Expand Down
9 changes: 2 additions & 7 deletions postal/pyexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,6 @@ static PyObject *py_expand(PyObject *self, PyObject *args, PyObject *keywords) {
Py_DECREF(seq);
}

if (languages == NULL) {
PyErr_SetString(PyExc_TypeError, "Must specify languages=[list of language codes] to expand_address");
goto exit_decref_str;
}


size_t num_expansions = 0;
char **expansions = expand_address(input, options, &num_expansions);

Expand Down Expand Up @@ -264,6 +258,7 @@ static int expand_traverse(PyObject *m, visitproc visit, void *arg) {

static int expand_clear(PyObject *m) {
Py_CLEAR(GETSTATE(m)->error);
libpostal_language_classifier_teardown();
libpostal_teardown();
return 0;
}
Expand Down Expand Up @@ -315,7 +310,7 @@ init_expand(void) {
INITERROR;
}

if (!libpostal_setup()) {
if (!libpostal_setup() || !libpostal_setup_language_classifier()) {
PyErr_SetString(PyExc_TypeError,
"Error loading libpostal");
}
Expand Down

0 comments on commit 957903c

Please sign in to comment.