RASMUS/Finnish-ASR-Canary-v2
01.2k
1# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14 15import pickle16 17import pandas as pd18from omegaconf import OmegaConf19 20from nemo.collections.common.tokenizers.column_coder import ColumnCodes21from nemo.core.config import hydra_runner22from nemo.utils import logging23 24 25@hydra_runner(config_path="conf", config_name="tabular_data_tokenizer")26def main(cfg) -> None:27 logging.info("\n\n************** Experiment configuration ***********")28 logging.info(OmegaConf.to_yaml(cfg))29 table = pd.read_csv(cfg.table_csv_file)30 example_arrays = {}31 for col in cfg.table_structure:32 col_name = col['name']33 example_arrays[col_name] = table[col_name].dropna().unique()34 cc = ColumnCodes.get_column_codes(cfg.table_structure, example_arrays)35 with open(cfg.tokenizer_file, 'wb') as handle:36 pickle.dump(cc, handle)37 38 39if __name__ == '__main__':40 main()41 