1#cython: language_level=3 2# Copyright 2005-2020 Google LLC 3# 4# Licensed under the Apache License, Version 2.0 (the 'License'); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an 'AS IS' BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# See www.openfst.org for extensive documentation on this weighted 17# finite-state transducer library. 18 19 20from libcpp cimport bool 21from libcpp.memory cimport unique_ptr 22from libcpp.string cimport string 23from libcpp.vector cimport vector 24from libcpp.utility cimport pair 25 26from cios cimport * 27from cintegral_types cimport * 28 29 30cdef extern from "<fst/util.h>" nogil: 31 32 bool FST_FLAGS_fst_error_fatal 33 34 35cdef extern from "<fst/fstlib.h>" namespace "fst" nogil: 36 37 # FST properties. 38 const uint64 kExpanded 39 const uint64 kMutable 40 const uint64 kError 41 const uint64 kAcceptor 42 const uint64 kNotAcceptor 43 const uint64 kIDeterministic 44 const uint64 kNonIDeterministic 45 const uint64 kODeterministic 46 const uint64 kNonODeterministic 47 const uint64 kEpsilons 48 const uint64 kNoEpsilons 49 const uint64 kIEpsilons 50 const uint64 kNoIEpsilons 51 const uint64 kOEpsilons 52 const uint64 kNoOEpsilons 53 const uint64 kILabelSorted 54 const uint64 kNotILabelSorted 55 const uint64 kOLabelSorted 56 const uint64 kNotOLabelSorted 57 const uint64 kWeighted 58 const uint64 kUnweighted 59 const uint64 kCyclic 60 const uint64 kAcyclic 61 const uint64 kInitialCyclic 62 const uint64 kInitialAcyclic 63 const uint64 kTopSorted 64 const uint64 kNotTopSorted 65 const uint64 kAccessible 66 const uint64 kNotAccessible 67 const uint64 kCoAccessible 68 const uint64 kNotCoAccessible 69 const uint64 kString 70 const uint64 kNotString 71 const uint64 kWeightedCycles 72 const uint64 kUnweightedCycles 73 const uint64 kNullProperties 74 const uint64 kCopyProperties 75 const uint64 kIntrinsicProperties 76 const uint64 kExtrinsicProperties 77 const uint64 kSetStartProperties 78 const uint64 kSetFinalProperties 79 const uint64 kAddStateProperties 80 const uint64 kAddArcProperties 81 const uint64 kSetArcProperties 82 const uint64 kDeleteStatesProperties 83 const uint64 kDeleteArcsProperties 84 const uint64 kStateSortProperties 85 const uint64 kArcSortProperties 86 const uint64 kILabelInvariantProperties 87 const uint64 kOLabelInvariantProperties 88 const uint64 kWeightInvariantProperties 89 const uint64 kAddSuperFinalProperties 90 const uint64 kRmSuperFinalProperties 91 const uint64 kBinaryProperties 92 const uint64 kTrinaryProperties 93 const uint64 kPosTrinaryProperties 94 const uint64 kNegTrinaryProperties 95 const uint64 kFstProperties 96 97 # ArcIterator flags. 98 const uint8 kArcILabelValue 99 const uint8 kArcOLabelValue 100 const uint8 kArcWeightValue 101 const uint8 kArcNextStateValue 102 const uint8 kArcNoCache 103 const uint8 kArcValueFlags 104 const uint8 kArcFlags 105 106 # EncodeMapper flags. 107 const uint8 kEncodeLabels 108 const uint8 kEncodeWeights 109 const uint8 kEncodeFlags 110 111 # Default argument constants. 112 const float kDelta 113 const float kShortestDelta 114 const int kNoLabel 115 const int kNoStateId 116 const int64 kNoSymbol 117 118 enum ClosureType: 119 CLOSURE_STAR 120 CLOSURE_PLUS 121 122 enum ComposeFilter: 123 AUTO_FILTER 124 NULL_FILTER 125 SEQUENCE_FILTER 126 ALT_SEQUENCE_FILTER 127 MATCH_FILTER 128 TRIVIAL_FILTER 129 130 cdef cppclass ComposeOptions: 131 132 ComposeOptions(bool, ComposeFilter) 133 134 enum DeterminizeType: 135 DETERMINIZE_FUNCTIONAL 136 DETERMINIZE_NONFUNCTIONAL 137 DETERMINIZE_DISAMBIGUATE 138 139 enum EncodeType: 140 DECODE 141 ENCODE 142 143 enum EpsNormalizeType: 144 EPS_NORM_INPUT 145 EPS_NORM_OUTPUT 146 147 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 148 # support: https://github.com/cython/cython/issues/1603 149 ctypedef enum ProjectType: 150 PROJECT_INPUT "fst::ProjectType::INPUT" 151 PROJECT_OUTPUT "fst::ProjectType::OUTPUT" 152 153 enum QueueType: 154 TRIVIAL_QUEUE 155 FIFO_QUEUE 156 LIFO_QUEUE 157 SHORTEST_FIRST_QUEUE 158 TOP_ORDER_QUEUE 159 STATE_ORDER_QUEUE 160 SCC_QUEUE 161 AUTO_QUEUE 162 OTHER_QUEUE 163 164 # This is a templated struct at the C++ level, but Cython does not support 165 # templated structs unless we pretend they are full-blown classes. 166 cdef cppclass RandGenOptions[RandArcSelection]: 167 168 RandGenOptions(const RandArcSelection &, int32, int32, bool, bool) 169 170 enum ReplaceLabelType: 171 REPLACE_LABEL_NEITHER 172 REPLACE_LABEL_INPUT 173 REPLACE_LABEL_OUTPUT 174 REPLACE_LABEL_BOTH 175 176 enum ReweightType: 177 REWEIGHT_TO_INITIAL 178 REWEIGHT_TO_FINAL 179 180 cdef cppclass SymbolTableTextOptions: 181 182 SymbolTableTextOptions(bool) 183 184 # This is actually a nested class, but Cython doesn't need to know that. 185 cdef cppclass SymbolTableIterator "fst::SymbolTable::iterator": 186 187 SymbolTableIterator(const SymbolTableIterator &) 188 189 cppclass value_type: 190 191 int64 Label() 192 string Symbol() 193 194 # When wrapped in a unique_ptr siter.Label() and siter.Symbol() are 195 # ambiguous to Cython because there's no way to make the -> explicit. 196 # This hacks around that. 197 const value_type &Pair "operator*"() 198 199 SymbolTableIterator &operator++() 200 201 bool operator==(const SymbolTableIterator &, const SymbolTableIterator &) 202 203 bool operator!=(const SymbolTableIterator &, const SymbolTableIterator &) 204 205 206 # Symbol tables. 207 cdef cppclass SymbolTable: 208 209 @staticmethod 210 int64 kNoSymbol 211 212 SymbolTable() 213 214 SymbolTable(const string &) 215 216 @staticmethod 217 SymbolTable *Read(const string &) 218 219 # Aliased for overload. 220 @staticmethod 221 SymbolTable *ReadStream "Read"(istream &, const string &) 222 223 @staticmethod 224 SymbolTable *ReadText(const string &, const SymbolTableTextOptions &) 225 226 int64 AddSymbol(const string &, int64) 227 228 int64 AddSymbol(const string &) 229 230 SymbolTable *Copy() 231 232 # Aliased for overload. 233 string FindSymbol "Find"(int64) 234 235 # Aliased for overload. 236 int64 FindIndex "Find"(const string &) 237 238 # Aliased for overload. 239 bool MemberSymbol "Member"(const string &) 240 241 # Aliased for overload. 242 bool MemberIndex "Member"(int64) 243 244 void AddTable(const SymbolTable &) 245 246 int64 GetNthKey(ssize_t) 247 248 const string &Name() 249 250 void SetName(const string &) 251 252 const string &CheckSum() 253 254 const string &LabeledCheckSum() 255 256 bool Write(ostream &) 257 258 bool Write(const string &) 259 260 bool WriteText(ostream &) 261 262 bool WriteText(const string &) 263 264 SymbolTableIterator begin() 265 266 SymbolTableIterator end() 267 268 int64 AvailableKey() 269 270 size_t NumSymbols() 271 272 SymbolTable *CompactSymbolTable(const SymbolTable &syms) 273 274 SymbolTable *MergeSymbolTable(const SymbolTable &, const SymbolTable &, 275 bool *) 276 277 SymbolTable *FstReadSymbols(const string &, bool) 278 279 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 280 # support: https://github.com/cython/cython/issues/1603. 281 ctypedef enum TokenType: 282 SYMBOL "fst::TokenType::SYMBOL" 283 BYTE "fst::TokenType::BYTE" 284 UTF8 "fst::TokenType::UTF8" 285 286 287cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil: 288 289 cdef cppclass WeightClass: 290 291 WeightClass() 292 293 WeightClass(const WeightClass &) 294 295 WeightClass(const string &, const string &) 296 297 const string &Type() 298 299 string ToString() 300 301 bool Member() 302 303 @staticmethod 304 const WeightClass &Zero(const string &) 305 306 @staticmethod 307 const WeightClass &One(const string &) 308 309 @staticmethod 310 const WeightClass &NoWeight(const string &) 311 312 # Alias. 313 cdef bool Eq "operator=="(const WeightClass &, const WeightClass &) 314 315 # Alias. 316 cdef bool Ne "operator!="(const WeightClass &, const WeightClass &) 317 318 cdef WeightClass Plus(const WeightClass &, const WeightClass &) 319 320 cdef WeightClass Times(const WeightClass &, const WeightClass &) 321 322 cdef WeightClass Divide(const WeightClass &, const WeightClass &) 323 324 cdef WeightClass Power(const WeightClass &, size_t) 325 326 cdef cppclass ArcClass: 327 328 ArcClass(const ArcClass &) 329 330 ArcClass(int64, int64, const WeightClass &, int64) 331 332 int64 ilabel 333 int64 olabel 334 WeightClass weight 335 int64 nextstate 336 337 cdef cppclass FstClass: 338 339 FstClass(const FstClass &) 340 341 @staticmethod 342 FstClass *Read(const string &) 343 344 # Aliased for overload. 345 @staticmethod 346 FstClass *ReadStream "Read"(istream &, const string &) 347 348 int64 Start() 349 350 WeightClass Final(int64) 351 352 size_t NumArcs(int64) 353 354 size_t NumInputEpsilons(int64) 355 356 size_t NumOutputEpsilons(int64) 357 358 const string &ArcType() 359 360 const string &FstType() 361 362 const SymbolTable *InputSymbols() 363 364 const SymbolTable *OutputSymbols() 365 366 const string &WeightType() 367 368 bool Write(const string &) 369 370 bool Write(ostream &, const string &) 371 372 uint64 Properties(uint64, bool) 373 374 bool ValidStateId(int64) 375 376 cdef cppclass MutableFstClass(FstClass): 377 378 bool AddArc(int64, const ArcClass &) 379 380 int64 AddState() 381 382 void AddStates(size_t) 383 384 bool DeleteArcs(int64, size_t) 385 386 bool DeleteArcs(int64) 387 388 bool DeleteStates(const vector[int64] &) 389 390 void DeleteStates() 391 392 SymbolTable *MutableInputSymbols() 393 394 SymbolTable *MutableOutputSymbols() 395 396 int64 NumStates() 397 398 bool ReserveArcs(int64, size_t) 399 400 void ReserveStates(int64) 401 402 bool SetStart(int64) 403 404 bool SetFinal(int64, const WeightClass &) 405 406 void SetInputSymbols(const SymbolTable *) 407 408 void SetOutputSymbols(const SymbolTable *) 409 410 void SetProperties(uint64, uint64) 411 412 cdef cppclass VectorFstClass(MutableFstClass): 413 414 VectorFstClass(const FstClass &) 415 416 VectorFstClass(const string &) 417 418 cdef cppclass EncodeMapperClass: 419 420 EncodeMapperClass(const string &, uint32, EncodeType) 421 422 # Aliased to __call__ as Cython doesn't have good support for operator(). 423 ArcClass __call__ "operator()"(const ArcClass &) 424 425 const string &ArcType() 426 427 const string &WeightType() 428 429 uint32 Flags() 430 431 uint64 Properties(uint64) 432 433 @staticmethod 434 EncodeMapperClass *Read(const string &) 435 436 # Aliased for overload. 437 @staticmethod 438 EncodeMapperClass *ReadStream "Read"(istream &, const string &) 439 440 bool Write(const string &) 441 442 # Aliased for overload. 443 bool WriteStream "Write"(ostream &, const string &) 444 445 const SymbolTable *InputSymbols() 446 447 const SymbolTable *OutputSymbols() 448 449 void SetInputSymbols(const SymbolTable *) 450 451 void SetOutputSymbols(const SymbolTable *) 452 453 cdef cppclass ArcIteratorClass: 454 455 ArcIteratorClass(const FstClass &, int64) 456 457 bool Done() 458 459 ArcClass Value() 460 461 void Next() 462 463 void Reset() 464 465 void Seek(size_t) 466 467 size_t Position() 468 469 uint8 Flags() 470 471 void SetFlags(uint8, uint8) 472 473 cdef cppclass MutableArcIteratorClass: 474 475 MutableArcIteratorClass(MutableFstClass *, int64) 476 477 bool Done() 478 479 ArcClass Value() 480 481 void Next() 482 483 void Reset() 484 485 void Seek(size_t) 486 487 void SetValue(const ArcClass &) 488 489 size_t Position() 490 491 uint8 Flags() 492 493 void SetFlags(uint8, uint8) 494 495 cdef cppclass StateIteratorClass: 496 497 StateIteratorClass(const FstClass &) 498 499 bool Done() 500 501 int64 Value() 502 503 void Next() 504 505 void Reset() 506 507 508ctypedef pair[int64, const FstClass *] LabelFstClassPair 509 510ctypedef pair[int64, int64] LabelPair 511 512 513cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil: 514 515 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 516 # support: https://github.com/cython/cython/issues/1603 517 ctypedef enum ArcFilterType: 518 ANY_ARC_FILTER "fst::script::ArcFilterType::ANY" 519 EPSILON_ARC_FILTER "fst::script::ArcFilterType::EPSILON" 520 INPUT_EPSILON_ARC_FILTER "fst::script::ArcFilterType::INPUT_EPSILON" 521 OUTPUT_EPSILON_ARC_FILTER "fst::script::ArcFilterType::OUTPUT_EPSILON" 522 523 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 524 # support: https://github.com/cython/cython/issues/1603 525 ctypedef enum ArcSortType: 526 ILABEL_SORT "fst::script::ArcSortType::ILABEL" 527 OLABEL_SORT "fst::script::ArcSortType::OLABEL" 528 529 cdef void ArcSort(MutableFstClass *, ArcSortType) 530 531 cdef ClosureType GetClosureType(bool) 532 533 cdef void Closure(MutableFstClass *, ClosureType) 534 535 cdef unique_ptr[FstClass] CompileFstInternal(istream &, 536 const string &, 537 const string &, 538 const string &, 539 const SymbolTable *, 540 const SymbolTable *, 541 const SymbolTable*, 542 bool, 543 bool, 544 bool, 545 bool, 546 bool) 547 548 cdef void Compose(FstClass &, FstClass &, MutableFstClass *, 549 const ComposeOptions &) 550 551 cdef void Concat(MutableFstClass *, const FstClass &) 552 553 cdef void Connect(MutableFstClass *) 554 555 cdef unique_ptr[FstClass] Convert(const FstClass &, const string &) 556 557 cdef void Decode(MutableFstClass *, const EncodeMapperClass &) 558 559 cdef cppclass DeterminizeOptions: 560 561 DeterminizeOptions(float, 562 const WeightClass &, 563 int64, 564 int64, 565 DeterminizeType, 566 bool) 567 568 cdef void Determinize(const FstClass &, 569 MutableFstClass *, 570 const DeterminizeOptions &) 571 572 cdef cppclass DisambiguateOptions: 573 574 DisambiguateOptions(float, const WeightClass &, int64, int64) 575 576 cdef void Disambiguate(const FstClass &, 577 MutableFstClass *, 578 const DisambiguateOptions &) 579 580 cdef void Difference(const FstClass &, 581 const FstClass &, 582 MutableFstClass *, 583 const ComposeOptions &) 584 585 cdef void Draw(const FstClass &fst, 586 const SymbolTable *, 587 const SymbolTable *, 588 const SymbolTable *, 589 bool, 590 const string &, 591 float, 592 float, 593 bool, 594 bool, 595 float, 596 float, 597 int, 598 int, 599 const string &, 600 bool, 601 ostream &, 602 const string &) 603 604 cdef void Encode(MutableFstClass *, EncodeMapperClass *) 605 606 cdef EpsNormalizeType GetEpsNormalizeType(bool) 607 608 cdef void EpsNormalize(const FstClass &, MutableFstClass *, EpsNormalizeType) 609 610 cdef bool Equal(const FstClass &, const FstClass &, float) 611 612 cdef bool Equivalent(const FstClass &, const FstClass &, float) 613 614 cdef void Intersect(const FstClass &, 615 const FstClass &, 616 MutableFstClass *, 617 const ComposeOptions &) 618 619 cdef void Invert(MutableFstClass *fst) 620 621 cdef bool Isomorphic(const FstClass &, const FstClass &, float) 622 623 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 624 # support: https://github.com/cython/cython/issues/1603 625 ctypedef enum MapType: 626 ARC_SUM_MAPPER "fst::script::MapType::ARC_SUM" 627 IDENTITY_MAPPER "fst::script::MapType::IDENTITY" 628 INPUT_EPSILON_MAPPER "fst::script::MapType::INPUT_EPSILON" 629 INVERT_MAPPER "fst::script::MapType::INVERT" 630 OUTPUT_EPSILON_MAPPER "fst::script::MapType::OUTPUT_EPSILON" 631 PLUS_MAPPER "fst::script::MapType::PLUS" 632 QUANTIZE_MAPPER "fst::script::MapType::QUANTIZE" 633 RMWEIGHT_MAPPER "fst::script::MapType::RMWEIGHT" 634 SUPERFINAL_MAPPER "fst::script::MapType::SUPERFINAL" 635 TIMES_MAPPER "fst::script::MapType::TIMES" 636 TO_LOG_MAPPER "fst::script::MapType::TO_LOG" 637 TO_LOG64_MAPPER "fst::script::MapType::TO_LOG64" 638 TO_STD_MAPPER "fst::script::MapType::TO_STD" 639 640 cdef unique_ptr[FstClass] Map(const FstClass &, 641 MapType, 642 float, 643 double, 644 const WeightClass &) 645 646 cdef void Minimize(MutableFstClass *, MutableFstClass *, float, bool) 647 648 cdef bool GetProjectType(const string &, ProjectType *) 649 650 cdef void Project(MutableFstClass *, ProjectType) 651 652 cdef void Print(const FstClass &, 653 ostream &, 654 const string &, 655 const SymbolTable *, 656 const SymbolTable *, 657 const SymbolTable *, 658 bool, 659 bool, 660 const string &) 661 662 cdef void Prune(const FstClass &, 663 MutableFstClass *, 664 const WeightClass &, 665 int64, float) 666 667 cdef void Prune(MutableFstClass *, const WeightClass &, int64, float) 668 669 cdef void Push(const FstClass &, 670 MutableFstClass *, 671 uint8 flags, 672 ReweightType, float) 673 674 cdef void Push(MutableFstClass *, ReweightType, float, bool) 675 676 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 677 # support: https://github.com/cython/cython/issues/1603 678 ctypedef enum RandArcSelection: 679 UNIFORM_ARC_SELECTOR "fst::script::RandArcSelection::UNIFORM" 680 LOG_PROB_ARC_SELECTOR "fst::script::RandArcSelection::LOG_PROB" 681 FAST_LOG_PROB_ARC_SELECTOR "fst::script::RandArcSelection::FAST_LOG_PROB" 682 683 cdef bool RandEquivalent(const FstClass &, 684 const FstClass &, 685 int32, 686 const RandGenOptions[RandArcSelection] &, 687 float, 688 uint64) 689 690 cdef void RandGen(const FstClass &, 691 MutableFstClass *, 692 const RandGenOptions[RandArcSelection] &, 693 uint64) 694 695 cdef void Relabel(MutableFstClass *, 696 const SymbolTable *, 697 const SymbolTable *, 698 const string &, bool, 699 const SymbolTable *, 700 const SymbolTable *, 701 const string &, 702 bool) 703 704 cdef void Relabel(MutableFstClass *, 705 const vector[LabelPair] &, 706 const vector[LabelPair] &) 707 708 cdef cppclass ReplaceOptions: 709 710 ReplaceOptions(int64, ReplaceLabelType, ReplaceLabelType, int64) 711 712 cdef void Replace(const vector[LabelFstClassPair] &, 713 MutableFstClass *, 714 const ReplaceOptions &) 715 716 cdef void Reverse(const FstClass &, MutableFstClass *, bool) 717 718 cdef void Reweight(MutableFstClass *, 719 const vector[WeightClass] &, 720 ReweightType) 721 722 cdef cppclass RmEpsilonOptions: 723 724 RmEpsilonOptions(QueueType, bool, const WeightClass &, int64, float) 725 726 cdef void RmEpsilon(MutableFstClass *, const RmEpsilonOptions &) 727 728 cdef cppclass ShortestDistanceOptions: 729 730 ShortestDistanceOptions(QueueType, ArcFilterType, int64, float) 731 732 cdef void ShortestDistance(const FstClass &, 733 vector[WeightClass] *, 734 const ShortestDistanceOptions &) 735 736 cdef void ShortestDistance(const FstClass &, 737 vector[WeightClass] *, bool, 738 float) 739 740 cdef cppclass ShortestPathOptions: 741 742 ShortestPathOptions(QueueType, 743 int32, 744 bool, 745 float, 746 const WeightClass &, 747 int64) 748 749 cdef void ShortestPath(const FstClass &, 750 MutableFstClass *, 751 const ShortestPathOptions &) 752 753 cdef void Synchronize(const FstClass &, MutableFstClass *) 754 755 cdef bool TopSort(MutableFstClass *) 756 757 cdef void Union(MutableFstClass *, const vector[FstClass *] &) 758 759 cdef bool Verify(const FstClass &) 760 761 762cdef extern from "<fst/script/getters.h>" namespace "fst::script" nogil: 763 764 cdef bool GetArcSortType(const string &, ArcSortType *) 765 766 cdef bool GetComposeFilter(const string &, ComposeFilter *) 767 768 cdef bool GetDeterminizeType(const string &, DeterminizeType *) 769 770 cdef uint8 GetEncodeFlags(bool, bool) 771 772 cdef bool GetMapType(const string &, MapType *) 773 774 cdef uint8 GetPushFlags(bool, bool, bool, bool) 775 776 cdef bool GetQueueType(const string &, QueueType *) 777 778 cdef bool GetRandArcSelection(const string &, RandArcSelection *) 779 780 cdef bool GetReplaceLabelType(string, bool, ReplaceLabelType *) 781 782 cdef ReweightType GetReweightType(bool) 783 784 cdef bool GetTokenType(const string &, TokenType *) 785 786 787cdef extern from "<fst/extensions/far/far.h>" namespace "fst" nogil: 788 789 # TODO(wolfsonkin): Don't do this hack if Cython gets proper enum class 790 # support: https://github.com/cython/cython/issues/1603 791 ctypedef enum FarType: 792 FAR_DEFAULT "fst::FarType::DEFAULT" 793 FAR_STTABLE "fst::FarType::STTABLE" 794 FAR_STLIST "fst::FarType::STLIST" 795 FAR_FST "fst::FarType::FST" 796 FAR_SSTABLE "fst::FarType::SSTABLE" 797 798cdef extern from "<fst/extensions/far/getters.h>" \ 799 namespace "fst" nogil: 800 801 string GetFarTypeString(FarType) 802 803 804cdef extern from "<fst/extensions/far/getters.h>" \ 805 namespace "fst::script" nogil: 806 807 bool GetFarType(const string &, FarType *) 808 809 810cdef extern from "<fst/extensions/far/far-class.h>" \ 811 namespace "fst::script" nogil: 812 813 cdef cppclass FarReaderClass: 814 815 const string &ArcType() 816 817 bool Done() 818 819 bool Error() 820 821 bool Find(const string &) 822 823 const FstClass *GetFstClass() 824 825 const string &GetKey() 826 827 void Next() 828 829 void Reset() 830 831 FarType Type() 832 833 # For simplicity, we always use the multiple-file one. 834 @staticmethod 835 unique_ptr[FarReaderClass] Open(const vector[string] &) 836 837 cdef cppclass FarWriterClass: 838 839 bool Add(const string &, const FstClass &) 840 841 bool Error() 842 843 const string &ArcType() 844 845 FarType Type() 846 847 @staticmethod 848 unique_ptr[FarWriterClass] Create(const string &, const string &, FarType) 849