dchaplinsky commited on
Commit
c924a51
1 Parent(s): d3bab7c

Create pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +21 -0
pipeline.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ import os
4
+ import fasttext.util
5
+
6
+ class PreTrainedPipeline():
7
+ def __init__(self, path=""):
8
+ """
9
+ Initialize model
10
+ """
11
+ self.model = fasttext.load_model(os.path.join(path, 'cbow.uk.300.bin'))
12
+
13
+ def __call__(self, inputs: str) -> List[float]:
14
+ """
15
+ Args:
16
+ inputs (:obj:`str`):
17
+ a string to get the features of.
18
+ Return:
19
+ A :obj:`list` of floats: The features computed by the model.
20
+ """
21
+ return self.model.get_sentence_vector(inputs).tolist()