File size: 1,030 Bytes
4fb0bd1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from abc import ABC, abstractclassmethod
class Field(ABC):
"""Abstract class `Field` define one indexing method,
genenrate counter from raw text data and index token in raw text data
Arguments:
ABC {ABC} -- abstract base class
"""
@abstractclassmethod
def count_vocab_items(self, counter, sentences):
"""This function constructs counter using each sentence content,
prepare for vocabulary
Arguments:
counter {dict} -- element count dict
sentences {list} -- text data
"""
raise NotImplementedError
@abstractclassmethod
def index(self, instance, voacb, sentences):
"""This function constrcuts instance using sentences and vocabulary,
each namespace is a mappping method using different type data
Arguments:
instance {dict} -- collections of various fields
voacb {dict} -- vocabulary
sentences {list} -- text data
"""
raise NotImplementedError
|