MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / AbstractPreproc

Class AbstractPreproc

rat-sql-gap/seq2struct/models/abstract_preproc.py:3–49  ·  view source on GitHub ↗

Used for preprocessing data according to the model's liking. Some tasks normally performed here: - Constructing a vocabulary from the training data - Transforming the items in some way, such as - Parsing the AST - - Loading and providing the pre-processed data to th

Source from the content-addressed store, hash-verified

1import abc
2
3class AbstractPreproc(metaclass=abc.ABCMeta):
4 '''Used for preprocessing data according to the model's liking.
5
6 Some tasks normally performed here:
7 - Constructing a vocabulary from the training data
8 - Transforming the items in some way, such as
9 - Parsing the AST
10 -
11 - Loading and providing the pre-processed data to the model
12
13 TODO:
14 - Allow transforming items in a streaming fashion without loading all of them into memory first
15 '''
16
17 @abc.abstractmethod
18 def validate_item(self, item, section):
19 '''Checks whether item can be successfully preprocessed.
20
21 Returns a boolean and an arbitrary object.'''
22 pass
23
24 @abc.abstractmethod
25 def add_item(self, item, section, validation_info):
26 '''Add an item to be preprocessed.'''
27 pass
28
29 @abc.abstractmethod
30 def clear_items(self):
31 '''Clear the preprocessed items'''
32 pass
33
34 @abc.abstractmethod
35 def save(self):
36 '''Marks that all of the items have been preprocessed. Save state to disk.
37
38 Used in preprocess.py, after reading all of the data.'''
39 pass
40
41 @abc.abstractmethod
42 def load(self):
43 '''Load state from disk.'''
44 pass
45
46 @abc.abstractmethod
47 def dataset(self, section):
48 '''Returns a torch.data.utils.Dataset instance.'''
49 pass

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected