Hellisotherpeople commited on
Commit
259afe6
1 Parent(s): 156189f

Create pipeline.py

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