From e73eaf2d055707d5ecc0285f6375b41a451c109a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 8 May 2015 16:52:17 +0200 Subject: [PATCH] * Replace some assertions with proper errors --- spacy/vocab.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index feb609c0e..188fe7069 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -144,7 +144,8 @@ cdef class Vocab: raise IOError('LexemeCs file not found at %s' % loc) cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc cdef FILE* fp = fopen(bytes_loc, b'rb') - assert fp != NULL + if fp == NULL: + raise IOError('lexemes data file present, but cannot open from ' % loc) cdef size_t st cdef LexemeC* lexeme cdef attr_t orth @@ -161,7 +162,9 @@ cdef class Vocab: lexeme.repvec = EMPTY_VEC if st != 1: break - assert orth == lexeme.orth + if orth != lexeme.orth: + # TODO: Improve this error message, pending resolution to Issue #64 + raise IOError('Error reading from lexemes.bin. Integrity check fails.') py_str = self.strings[orth] key = hash_string(py_str) self._map.set(key, lexeme)