Saves the model as a pickle file at the given path. The advantage is that cached vectors and cosine similarity are stored.
(self, path, update=False)
| 825 | return cPickle.load(open(path)) |
| 826 | |
| 827 | def save(self, path, update=False): |
| 828 | """ Saves the model as a pickle file at the given path. |
| 829 | The advantage is that cached vectors and cosine similarity are stored. |
| 830 | """ |
| 831 | if update: |
| 832 | # Update the entire cache before saving. |
| 833 | for d1 in self.documents: |
| 834 | for d2 in self.documents: |
| 835 | self.cosine_similarity(d1, d2) |
| 836 | m = dict.fromkeys((d.id for d in self.documents), True) |
| 837 | for id1, id2 in self._cos.keys(): |
| 838 | # Remove Model.search() query cache. |
| 839 | if id1 not in m \ |
| 840 | or id2 not in m: |
| 841 | self._cos.pop((id1, id2)) |
| 842 | cPickle.dump(self, open(path, "wb"), 1) # 1 = binary |
| 843 | |
| 844 | def export(self, path, format=ORANGE, **kwargs): |
| 845 | """ Exports the model as a file for other machine learning applications, |
nothing calls this directly
no test coverage detected