debate2vec / pipeline.py
Hellisotherpeople's picture
Create pipeline.py
259afe6
from typing import List
import os
import fasttext.util
class PreTrainedPipeline():
def __init__(self, path=""):
"""
Initialize model
"""
self.model = fasttext.load_model(os.path.join(path, 'debate2vec.bin'))
def __call__(self, inputs: str) -> List[float]:
"""
Args:
inputs (:obj:`str`):
a string to get the features of.
Return:
A :obj:`list` of floats: The features computed by the model.
"""
return self.model.get_sentence_vector(inputs).tolist()