File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ impl PyEmbeddings {
5959 Ok ( ( ) )
6060 }
6161
62+ /// read_fasttext(path,/)
63+ /// --
64+ ///
65+ /// Read embeddings in the fasttext format.
66+ #[ staticmethod]
67+ fn read_fasttext ( path : & str ) -> PyResult < PyEmbeddings > {
68+ read_non_fifu_embeddings ( path, |r| Embeddings :: read_fasttext ( r) )
69+ }
70+
6271 /// read_text(path,/)
6372 /// --
6473 ///
@@ -338,9 +347,11 @@ where
338347 Ok ( embeddings)
339348}
340349
341- fn read_non_fifu_embeddings < R > ( path : & str , read_embeddings : R ) -> PyResult < PyEmbeddings >
350+ fn read_non_fifu_embeddings < R , V > ( path : & str , read_embeddings : R ) -> PyResult < PyEmbeddings >
342351where
343- R : FnOnce ( & mut BufReader < File > ) -> ffio:: Result < Embeddings < SimpleVocab , NdArray > > ,
352+ R : FnOnce ( & mut BufReader < File > ) -> ffio:: Result < Embeddings < V , NdArray > > ,
353+ V : Vocab ,
354+ Embeddings < VocabWrap , StorageViewWrap > : From < Embeddings < V , NdArray > > ,
344355{
345356 let f = File :: open ( path) . map_err ( |err| {
346357 exceptions:: IOError :: py_err ( format ! (
You can’t perform that action at this time.
0 commit comments