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.

77 lines
2.6 KiB

  1. // Copyright 2005-2024 Google LLC
  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 at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // 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 and
  13. // limitations under the License.
  14. //
  15. // See www.openfst.org for extensive documentation on this weighted
  16. // finite-state transducer library.
  17. #ifndef FST_SCRIPT_DRAW_H_
  18. #define FST_SCRIPT_DRAW_H_
  19. #include <ostream>
  20. #include <string>
  21. #include <fst/fst.h>
  22. #include <fst/symbol-table.h>
  23. #include <fst/script/draw-impl.h>
  24. #include <fst/script/fst-class.h>
  25. namespace fst {
  26. namespace script {
  27. // Note: it is safe to pass these strings as references because this struct is
  28. // only used to pass them deeper in the call graph. Be sure you understand why
  29. // this is so before using this struct for anything else!
  30. struct FstDrawArgs {
  31. const FstClass &fst;
  32. const SymbolTable *isyms;
  33. const SymbolTable *osyms;
  34. const SymbolTable *ssyms;
  35. const bool accep;
  36. const std::string &title;
  37. const float width;
  38. const float height;
  39. const bool portrait;
  40. const bool vertical;
  41. const float ranksep;
  42. const float nodesep;
  43. const int fontsize;
  44. const int precision;
  45. const std::string &float_format;
  46. const bool show_weight_one;
  47. std::ostream &ostrm;
  48. const std::string &dest;
  49. };
  50. template <class Arc>
  51. void Draw(FstDrawArgs *args) {
  52. const Fst<Arc> &fst = *args->fst.GetFst<Arc>();
  53. FstDrawer<Arc> fstdrawer(fst, args->isyms, args->osyms, args->ssyms,
  54. args->accep, args->title, args->width, args->height,
  55. args->portrait, args->vertical, args->ranksep,
  56. args->nodesep, args->fontsize, args->precision,
  57. args->float_format, args->show_weight_one);
  58. fstdrawer.Draw(args->ostrm, args->dest);
  59. }
  60. void Draw(const FstClass &fst, const SymbolTable *isyms,
  61. const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
  62. const std::string &title, float width, float height, bool portrait,
  63. bool vertical, float ranksep, float nodesep, int fontsize,
  64. int precision, const std::string &float_format, bool show_weight_one,
  65. std::ostream &ostrm, const std::string &dest);
  66. } // namespace script
  67. } // namespace fst
  68. #endif // FST_SCRIPT_DRAW_H_