| 2347 | return self._classify(document, probability=not discrete) |
| 2348 | |
| 2349 | def save(self, path): |
| 2350 | svm, model = self._svm, self._model |
| 2351 | if model is not None: |
| 2352 | # Convert the SVM model to a string, save the string: |
| 2353 | _save = self.extension == LIBLINEAR and \ |
| 2354 | svm.liblinearutil.save_model or \ |
| 2355 | svm.libsvmutil.svm_save_model |
| 2356 | _save(path, model[0]) |
| 2357 | self._svm = None |
| 2358 | self._model = ((open(path).read(),) + model[1:]) if model else None |
| 2359 | Classifier.save(self, path) |
| 2360 | self._svm = svm |
| 2361 | self._model = model |
| 2362 | |
| 2363 | @classmethod |
| 2364 | def load(cls, path): |