Skip to content

Commit

Permalink
Add base process again
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu315 committed Oct 6, 2022
1 parent d6b17ba commit 09c6302
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dataprofiler/labelers/base_data_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, dirpath: str = None, load_options: Dict = None) -> None:
# Example: self._preprocessor and self._postprocessor are instances of
# DataProcessing
self._preprocessor: data_processing.BaseDataPreprocessor = None # type: ignore
self._postprocessor: data_processing.BaseDataPostprocessor = ( # type: ignore
None
self._postprocessor: data_processing.BaseDataPostprocessor = (
None # type: ignore
)

# load default model
Expand Down
25 changes: 15 additions & 10 deletions dataprofiler/labelers/data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def set_params(self, **kwargs: Any) -> None:
for param in kwargs:
self._parameters[param] = kwargs[param]

@abc.abstractmethod
def process(self, *args):
"""Process data."""
raise NotImplementedError()

@classmethod
def load_from_disk(cls: Type[Processor], dirpath: str) -> Processor:
"""Load data processor from a given path on disk."""
Expand Down Expand Up @@ -175,7 +180,7 @@ def __init__(self, **parameters: Any) -> None:
super(BaseDataPreprocessor, self).__init__(**parameters)

@abc.abstractmethod
def process(
def process( # type: ignore
self,
data: np.ndarray,
labels: np.ndarray = None,
Expand All @@ -197,7 +202,7 @@ def __init__(self, **parameters):
super(BaseDataPostprocessor, self).__init__(**parameters)

@abc.abstractmethod
def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down Expand Up @@ -674,7 +679,7 @@ def gen_none() -> Generator[None, None, None]:
if batch_data["samples"]:
yield batch_data

def process(
def process( # type: ignore
self,
data: np.ndarray,
labels: np.ndarray = None,
Expand Down Expand Up @@ -842,7 +847,7 @@ def _validate_parameters(self, parameters: Dict) -> None:
if errors:
raise ValueError("\n".join(errors))

def process(
def process( # type: ignore
self,
data: np.ndarray,
labels: np.ndarray = None,
Expand Down Expand Up @@ -1275,7 +1280,7 @@ def match_sentence_lengths(

return results

def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down Expand Up @@ -1444,7 +1449,7 @@ def convert_to_unstructured_format(

return text, entities

def process(
def process( # type: ignore
self,
data: np.ndarray,
labels: np.ndarray = None,
Expand Down Expand Up @@ -1805,7 +1810,7 @@ def convert_to_structured_analysis(

return results

def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down Expand Up @@ -2027,7 +2032,7 @@ def split_prediction(results) -> None:
pred, axis=1, ord=1, keepdims=True
)

def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down Expand Up @@ -2165,7 +2170,7 @@ def _save_processor(self, dirpath: str) -> None:
) as fp:
json.dump(params, fp)

def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down Expand Up @@ -2258,7 +2263,7 @@ def help(cls) -> None:
)
print(help_str)

def process(
def process( # type: ignore
self,
data: np.ndarray,
results: Dict,
Expand Down

0 comments on commit 09c6302

Please sign in to comment.