You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2 KiB

  1. // util/simple-io-funcs.h
  2. // Copyright 2009-2011 Microsoft Corporation; Jan Silovsky
  3. // See ../../COPYING for clarification regarding multiple authors
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10. // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  11. // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  12. // MERCHANTABLITY OR NON-INFRINGEMENT.
  13. // See the Apache 2 License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef KALDI_UTIL_SIMPLE_IO_FUNCS_H_
  16. #define KALDI_UTIL_SIMPLE_IO_FUNCS_H_
  17. #include <string>
  18. #include <vector>
  19. #include "util/kaldi-io.h"
  20. // This header contains some utilities for reading some common, simple text
  21. // formats:integers in files, one per line, and integers in files, possibly
  22. // multiple per line. these are not really fully native Kaldi formats; they are
  23. // mostly for small files that might be generated by scripts, and can be read
  24. // all at one time. for longer files of this type, we would probably use the
  25. // Table code.
  26. namespace kaldi {
  27. /// WriteToList attempts to write this list of integers, one per line,
  28. /// to the given file, in text format.
  29. /// returns true if succeeded.
  30. bool WriteIntegerVectorSimple(const std::string& wxfilename,
  31. const std::vector<int32>& v);
  32. /// ReadFromList attempts to read this list of integers, one per line,
  33. /// from the given file, in text format.
  34. /// returns true if succeeded.
  35. bool ReadIntegerVectorSimple(const std::string& rxfilename,
  36. std::vector<int32>* v);
  37. // This is a file format like:
  38. // 1 2
  39. // 3
  40. //
  41. // 4 5 6
  42. // etc.
  43. bool WriteIntegerVectorVectorSimple(const std::string& wxfilename,
  44. const std::vector<std::vector<int32> >& v);
  45. bool ReadIntegerVectorVectorSimple(const std::string& rxfilename,
  46. std::vector<std::vector<int32> >* v);
  47. } // end namespace kaldi.
  48. #endif // KALDI_UTIL_SIMPLE_IO_FUNCS_H_