INNER CODE UNIT · Python
__add__
liyucheng09/Selective_Context · app/app.py:20
def __add__(self, other):
assert self.unit_type == other.unit_type, 'Cannot add two different unit types'
return LexicalUnits(self.unit_type, self.text + other.text, self.self_info + other.self_info)
def __radd__(self, other):
if other == 0:
return self
return NotImplementedError()
def add_to_head(self, token, self_info):
return LexicalUnits(self.unit_type, [token] + self.text, [self_info] + self.self_info)
def add_to_tail(self, token, self_info):
return LexicalUnits(self.unit_type, self.text + [token], self.self_info + [self_info])
class SelectiveContext:
def __init__(self, model_type = 'gpt2', lang = 'en'):