-
Notifications
You must be signed in to change notification settings - Fork 1
/
docstrings.i
3377 lines (2379 loc) · 80.9 KB
/
docstrings.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File: classhfst_1_1AttReader.xml
%feature("docstring") hfst::AttReader
"""
A class for reading input in AT&T text format and converting it into
transducer(s).
An example that reads AT&T input from file 'testfile.att' where epsilon is
represented as \"<eps>\" and creates the corresponding transducers and prints
them. If the input cannot be parsed, a message showing the invalid line in AT&T
input is printed and reading is stopped.
with open('testfile.att', 'r') as f:
try:
r = hfst.AttReader(f, \"<eps>\")
for tr in r:
print(tr)
except hfst.exceptions.NotValidAttFormatException as e:
print(e.what())
"""
%feature("docstring") hfst::AttReader::__init__
"""
Create an AttReader that reads input from file *f* where the epsilon is
represented as *epsilonstr*.
Parameters
----------
* `f` :
A python file.
* `epsilonstr` :
How epsilon is represented in the file. By default, \"@_EPSILON_SYMBOL_@\"
and \"@0@\" are both recognized.
"""
%feature("docstring") hfst::AttReader::__next__
"""
Return next element (for python version 3).
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
%feature("docstring") hfst::AttReader::read
"""
Read next transducer.
Read next transducer description in AT&T format and return a corresponding
transducer.
Exceptions
----------
* `hfst.exceptions.NotValidAttFormatException` :
* `hfst.exceptions.EndOfStreamException` :
"""
%feature("docstring") hfst::AttReader::__iter__
"""
An iterator to the reader.
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
"""
%feature("docstring") hfst::AttReader::next
"""
Return next element (for python version 2).
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
// File: classhfst_1_1HfstBasicTransducer.xml
%feature("docstring") hfst::HfstBasicTransducer
"""
A simple transducer class with tropical weights.
An example of creating an HfstBasicTransducer [foo:bar baz:baz] with weight 0.4
from scratch:
# Create an empty transducer
# The transducer has initially one start state (number zero)
# that is not final
fsm = hfst.HfstBasicTransducer()
# Add two states to the transducer
fsm.add_state(1)
fsm.add_state(2)
# Create a transition [foo:bar] leading to state 1 with weight 0.1
tr = hfst.HfstBasicTransition(1, 'foo', 'bar', 0.1)
# and add it to state zero
fsm.add_transition(0, tr)
# Add a transition [baz:baz] with weight 0 from state 1 to state 2
fsm.add_transition(1, hfst.HfstBasicTransition(2, 'baz', 'baz', 0.0))
# Set state 2 as final with weight 0.3
fsm.set_final_weight(2, 0.3)
An example of iterating through the states and transitions of the above
transducer when printing them in AT&T format to standard output:
# Go through all states
for state, arcs in enumerate(fsm):
for arc in arcs:
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
See also: hfst.HfstBasicTransition
"""
%feature("docstring") hfst::HfstBasicTransducer::states_and_transitions
"""
The states and transitions of the transducer.
Returns
-------
A tuple of tuples of HfstBasicTransitions.
See also: hfst.HfstBasicTransducer.__enumerate__
"""
%feature("docstring") hfst::HfstBasicTransducer::get_final_weight
"""
Get the final weight of state *state* in this transducer.
Parameters
----------
* `state` :
The number of the state. If it does not exist, a StateIsNotFinalException is
thrown.
Exceptions
----------
* `hfst.exceptions.StateIsNotFinalException.` :
"""
%feature("docstring") hfst::HfstBasicTransducer::__init__
"""
Create a transducer with one initial state that has state number zero and is not
a final state, i.e.
create an empty transducer.
tr = hfst.HfstBasicTransducer()
"""
%feature("docstring") hfst::HfstBasicTransducer::__init__
"""
Create a transducer equivalent to *transducer*.
Parameters
----------
* `transducer` :
The transducer to be copied, hfst.HfstBasicTransducer or
hfst.HfstTransducer.
tr = hfst.regex('foo') # creates an HfstTransducer
TR = hfst.HfstBasicTransducer(tr)
TR2 = hfst.HfstBasicTransducer(TR)
"""
%feature("docstring") hfst::HfstBasicTransducer::symbols_used
"""
Get a list of all symbols used in the transitions of this transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_symbol_from_alphabet
"""
Remove symbol *symbol* from the alphabet of the graph.
note: Use with care, removing symbols that occur in the transitions of the graph
can have unexpected results.
Parameters
----------
* `symbol` :
The string to be removed.
"""
%feature("docstring") hfst::HfstBasicTransducer::get_transition_pairs
"""
Get a list of all input/output symbol pairs used in the transitions of this
transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous.
A transducer is infinitely ambiguous if there exists an input that will yield
infinitely many results, i.e. there are input epsilon loops that are traversed
with that input.
"""
%feature("docstring") hfst::HfstBasicTransducer::harmonize
"""
Harmonize this transducer and *another*.
In harmonization the unknown and identity symbols in transitions of both graphs
are expanded according to the symbols that are previously unknown to the graph.
For example the graphs
[a:b ?:?]
[c:d ? ?:c] are expanded to
[ a:b [?:? | ?:c | ?:d | c:d | d:c | c:? | d:?] ]
[ c:d [? | a | b] [?:c| a:c | b:?] ] when harmonized.
The symbol '?' means hfst.UNKNOWN in either or both sides of a transition
(transitions of type [?:x], [x:?] and [?:?]). The transition [?] means
hfst.IDENTITY.
note: This function is always called for all transducer arguments of functions
that take two or more graphs as their arguments, unless otherwise said.
"""
%feature("docstring") hfst::HfstBasicTransducer::sort_arcs
"""
Sort the arcs of this transducer according to input and output symbols.
Returns
-------
This transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::states
"""
The states of the transducer.
Returns
-------
A tuple of state numbers.
An example: /verbatim for state in fsm.states(): for arc in
fsm.transitions(state): print('i ' % (state), end='') print(arc) if
fsm.is_final_state(state): print('i f' % (state, fsm.get_final_weight(state)) )
/endverbatim
"""
%feature("docstring") hfst::HfstBasicTransducer::get_max_state
"""
Get the biggest state number in use.
Returns
-------
The biggest state number in use.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_state
"""
Add a new state to this transducer and return its number.
Returns
-------
The next (smallest) free state number.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_state
"""
Add a state *s* to this graph.
Parameters
----------
* `state` :
The number of the state to be added.
Returns
-------
*state*
If the state already exists, it is not added again. All states with state number
smaller than *s* are also added to the transducer if they did not exist before.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_att
"""
Write this transducer in AT&T format to file *f*, *write_weights* defines
whether weights are written.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_symbols_from_alphabet
"""
Remove symbols *symbols* from the alphabet of the graph.
note: Use with care, removing symbols that occur in the transitions of the graph
can have unexpected results.
Parameters
----------
* `symbols` :
A tuple of strings to be removed.
"""
%feature("docstring") hfst::HfstBasicTransducer::__enumerate__
"""
Return an enumeration of the states and transitions of the transducer.
for state, arcs in enumerate(fsm):
for arc in arcs:
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
"""
%feature("docstring") hfst::HfstBasicTransducer::longest_path_size
"""
The length of the longest path in transducer.
Length of a path means number of arcs on that path.
"""
%feature("docstring") hfst::HfstBasicTransducer::get_alphabet
"""
The symbols in the alphabet of the transducer.
The symbols do not necessarily occur in any transitions of the transducer.
Epsilon, unknown and identity symbols are always included in the alphabet.
Returns
-------
A tuple of strings.
"""
%feature("docstring") hfst::HfstBasicTransducer::substitute
"""
Substitute symbols or transitions in the transducer.
Parameters
----------
* `s` :
The symbol or transition to be substituted. Can also be a dictionary of
substitutions, if S == None.
* `S` :
The symbol, transition, a tuple of transitions or a transducer
(hfst.HfstBasicTransducer) that substitutes *s*.
* `kvargs` :
Arguments recognized are 'input' and 'output', their values can be False or
True, True being the default. These arguments are valid only if *s* and *S*
are strings, else they are ignored.
* `input` :
Whether substitution is performed on input side, defaults to True. Valid
only if *s* and *S* are strings.
* `output` :
Whether substitution is performed on output side, defaults to True. Valid
only if *s* and *S* are strings.
Possible combinations of arguments and their types are:
(1) substitute(str, str, input=bool, output=bool): substitute symbol with symbol
on input, output or both sides of each transition in the transducer. (2)
substitute(strpair, strpair): substitute transition with transition (3)
substitute(strpair, strpairtuple): substitute transition with several
transitions (4) substitute(strpair, transducer): substitute transition with a
transducer (5) substitute(dict): perform several symbol-to-symbol substitutions
(6) substitute(dict): perform several transition-to-transition substitutions
Examples:
(1) tr.substitute('a', 'A', input=True, output=False): substitute lowercase a:s
with uppercase ones (2) tr.substitute(('a','b'),('A','B')): substitute
transitions that map lowercase a into lowercase b with transitions that map
uppercase a into uppercase b (3) tr.substitute(('a','b'),
(('A','B'),('a','B'),('A','b'))): change either or both sides of a transition
[a:b] to uppercase (4) tr.substitute(('a','b'), hfst.regex('[a:b]+')) change
[a:b] transition into one or more consecutive [a:b] transitions (5)
tr.substitute({'a':'A', 'b':'B', 'c':'C'}) change lowercase a, b and c into
their uppercase variants (6) tr.substitute( {('a','a'):('A','A'),
('b','b'):('B','B'), ('c','c'):('C','C')} ): change lowercase a, b and c into
their uppercase variants
In case (4), epsilon transitions are used to attach copies of transducer *S*
between the SOURCE and TARGET state of each transition that is substituted. The
transition itself is deleted, but its weight is copied to the epsilon transition
leading from SOURCE to the initial state of *S*. Each final state of *S* is made
non-final and an epsilon transition leading to TARGET is attached to it. The
final weight is copied to the epsilon transition.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_transition
"""
Remove transition *transition* from state *s*.
Parameters
----------
* `s` :
The state which *transition* belongs to.
* `transition` :
The transition to be removed.
* `remove_symbols_from_alphabet` :
(?)
"""
%feature("docstring") hfst::HfstBasicTransducer::add_transition
"""
Add a transition *transition* to state *state*, *add_symbols_to_alphabet*
defines whether the transition symbols are added to the alphabet.
Parameters
----------
* `state` :
The number of the state where the transition is added. If it does not exist,
it is created.
* `transition` :
A hfst.HfstBasicTransition that is added to *state*.
* `add_symbols_to_alphabet` :
Whether the transition symbols are added to the alphabet of the transducer.
(In special cases this is not wanted.)
"""
%feature("docstring") hfst::HfstBasicTransducer::add_transition
"""
Add a transition from state *source* to state *target* with input symbol
*input*, output symbol *output* and weight *weight*.
Parameters
----------
* `source` :
The number of the state where the transition is added. If it does not exist,
it is created.
* `target` :
The number of the state where the transition leads. If it does not exist, it
is created. (?)
* `input` :
The input symbol of the transition.
* `output` :
The output symbol of the transition.
* `weight` :
The weight of the transition.
"""
%feature("docstring") hfst::HfstBasicTransducer::read_prolog
"""
Read a transducer from prolog file *f*.
*linecount* is incremented as lines are read (is it in python?).
Returns
-------
A transducer constructed by reading from file *file*. This function is a static
one.
"""
%feature("docstring") hfst::HfstBasicTransducer::lookup_fd
"""
Lookup tokenized input *input* in the transducer minding flag diacritics.
Parameters
----------
* `str` :
A list/tuple of strings to look up.
* `kvargs` :
infinite_cutoff=-1, max_weight=None
* `infinite_cutoff` :
Defaults to -1, i.e. infinite.
* `max_weight` :
Defaults to None, i.e. infinity.
"""
%feature("docstring") hfst::HfstBasicTransducer::prune_alphabet
"""
Remove all symbols that do not occur in transitions of the transducer from its
alphabet.
Epsilon, unknown and identity symbols are always included in the alphabet.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_prolog
"""
Write the transducer in prolog format to file *f*.
Name the transducer *name*.
"""
%feature("docstring") hfst::HfstBasicTransducer::disjunct
"""
Disjunct this transducer with a one-path transducer defined by consecutive
string pairs in *spv* that has weight *weight*.
pre: This graph must be a trie where all weights are in final states, i.e. all
transitions have a zero weight.
There is no way to test whether a graph is a trie, so the use of this function
is probably limited to fast construction of a lexicon. Here is an example:
lexicon = hfst.HfstBasicTransducer()
tok = hfst.HfstTokenizer()
lexicon.disjunct(tok.tokenize('dog'), 0.3)
lexicon.disjunct(tok.tokenize('cat'), 0.5)
lexicon.disjunct(tok.tokenize('elephant'), 1.6)
"""
%feature("docstring") hfst::HfstBasicTransducer::read_att
"""
Read a transducer in AT&T format from file *f*.
*epsilon_symbol* defines the symbol used for epsilon, *linecount* is incremented
as lines are read.
Returns
-------
A transducer constructed by reading from file *file*. This function is a static
one.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_symbol_to_alphabet
"""
Explicitly add *symbol* to the alphabet of the graph.
note: Usually the user does not have to take care of the alphabet of a graph.
This function can be useful in some special cases. @ param symbol The string
to be added.
"""
%feature("docstring") hfst::HfstBasicTransducer::__str__
"""
Return a string representation of the transducer.
print(fsm)
"""
%feature("docstring") hfst::HfstBasicTransducer::set_final_weight
"""
Set the final weight of state *state* in this transducer to *weight*.
If the state does not exist, it is created.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_symbols_to_alphabet
"""
Explicitly add *symbols* to the alphabet of the graph.
note: Usually the user does not have to take care of the alphabet of a graph.
This function can be useful in some special cases.
Parameters
----------
* `symbols` :
A tuple of strings to be added.
"""
%feature("docstring") hfst::HfstBasicTransducer::transitions
"""
Get the transitions of state *state* in this transducer.
If the state does not exist, a *StateIndexOutOfBoundsException* is thrown.
Returns
-------
A tuple of HfstBasicTransitions.
for state in fsm.states():
for arc in fsm.transitions(state):
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
"""
%feature("docstring") hfst::HfstBasicTransducer::insert_freely
"""
Insert freely any number of *symbol_pair* in the transducer with weight
*weight*.
Parameters
----------
* `symbol_pair` :
A string pair to be inserted.
* `weight` :
The weight of the inserted symbol pair.
"""
%feature("docstring") hfst::HfstBasicTransducer::insert_freely
"""
Insert freely any number of *transducer* in this transducer.
param transducer An HfstBasicTransducer to be inserted.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_xfst
"""
Write the transducer in xfst format to file *f*.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_final_state
"""
Whether state *state* is final.
Parameters
----------
* `state` :
The state whose finality is returned.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_lookup_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous with input *str*.
Parameters
----------
* `str` :
The input.
A transducer is infinitely ambiguous with a given input if the input yields
infinitely many results, i.e. there are input epsilon loops that are traversed
with the input.
"""
// File: classhfst_1_1HfstBasicTransition.xml
%feature("docstring") hfst::HfstBasicTransition
"""
A transition class that consists of a target state, input and output symbols and
a a tropical weight.
See also: hfst.HfstBasicTransducer
"""
%feature("docstring") hfst::HfstBasicTransition::get_input_symbol
"""
Get the input symbol of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_weight
"""
Get the weight of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_output_symbol
"""
Get the output symbol of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_target_state
"""
Get number of the target state of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::__init__
"""
Create an HfstBasicTransition leading to target state *state* with input symbol
*input*, output symbol *output* and weight *weight*.
Parameters
----------
* `state` :
Number of the target state.
* `input` :
The input string.
* `output` :
The output string.
* `weight` :
The weight.
Exceptions
----------
* `EmptyStringException` :
transition = hfst.HfstBasicTransition(1, 'foo', 'bar', 0.5)
"""
// File: classhfst_1_1HfstInputStream.xml
%feature("docstring") hfst::HfstInputStream
"""
A stream for reading HFST binary transducers.
An example:
istr = hfst.HfstInputStream('testfile1.hfst')
transducers = []
while not (istr.is_eof()):
transducers.append(istr.read())
istr.close()
print(\"Read %i transducers in total.\" % len(transducers))
For documentation on the HFST binary transducer format, see here.
"""
%feature("docstring") hfst::HfstInputStream::is_bad
"""
Whether badbit is set.
"""
%feature("docstring") hfst::HfstInputStream::is_eof
"""
Whether the stream is at end.
"""
%feature("docstring") hfst::HfstInputStream::__init__
"""
Create a stream for reading binary transducers.
Parameters
----------
* `filename` :
The name of the transducer file. If not given, standard input is used.
Exceptions
----------
* `StreamNotReadableException` :
* `NotTransducerStreamException` :
* `EndOfStreamException` :
* `TransducerHeaderException` :
istr_to_stdin = hfst.HfstInputStream()
istr_to_file = hfst.HfstInputStream(filename='transducer.hfst')
"""
%feature("docstring") hfst::HfstInputStream::read
"""
Return next transducer.
Exceptions
----------
* `EndOfStreamException` :
"""
%feature("docstring") hfst::HfstInputStream::close
"""
Close the stream.
If the stream points to standard input, nothing is done.
"""
%feature("docstring") hfst::HfstInputStream::get_type
"""
The type of the first transducer in the stream.
By default, all transducers in a stream have the same type, else a
TransducerTypeMismatchException is thrown when reading the first transducer that
has a different type than the previous ones.
"""
%feature("docstring") hfst::HfstInputStream::is_good
"""
Whether the state of the stream is good for input operations.
"""
// File: classhfst_1_1HfstOutputStream.xml
%feature("docstring") hfst::HfstOutputStream
"""
A stream for writing binary transducers.
An example:
res = ['foo:bar','0','0 - 0','\"?\":?','a* b+']
ostr = hfst.HfstOutputStream(filename='testfile1.hfst')
for re in res:
ostr.write(hfst.regex(re))
ostr.flush()
ostr.close()
For more information on HFST transducer structure, see this page.
"""
%feature("docstring") hfst::HfstOutputStream::close
"""
Close the stream.
If the stream points to standard output, nothing is done.
"""
%feature("docstring") hfst::HfstOutputStream::__init__
"""
Open a stream for writing binary transducers.
Parameters
----------
* `kvargs` :
Arguments recognized are filename, hfst_format, type.
* `filename` :
The name of the file where transducers are written. If the file exists, it
is overwritten. If *filename* is not given, transducers are written to
standard output.
* `hfst_format` :
Whether transducers are written in hfst format (default is True) or as such
in their backend format.
* `type` :
The type of the transducers that will be written to the stream. Default is
hfst.get_default_fst_type().
ostr = hfst.HfstOutputStream() # a stream for writing default type
transducers in hfst format to standard output
transducer = hfst.regex('foo:bar::0.5')
ostr.write(transducer)
ostr.flush()
ostr = hfst.HfstOutputStream(filename='transducer.sfst', hfst_format=False,
type=hfst.types.SFST_TYPE) # a stream for writing SFST_TYPE transducers in
their back-end format to a file
transducer1 = hfst.regex('foo:bar')
transducer1.convert(hfst.types.SFST_TYPE) # if not set as the default type
transducer2 = hfst.regex('bar:baz')
transducer2.convert(hfst.types.SFST_TYPE) # if not set as the default type
ostr.write(transducer1)
ostr.write(transducer2)
ostr.flush()
ostr.close()
"""
%feature("docstring") hfst::HfstOutputStream::flush
"""
Flush the stream.
"""
%feature("docstring") hfst::HfstOutputStream::write
"""
Write the transducer *transducer* in binary format to the stream.
All transducers must have the same type as the stream, else a
TransducerTypeMismatchException is thrown.
Exceptions
----------
* `hfst.exceptions.TransducerTypeMismatchException` :
"""
// File: classhfst_1_1HfstTransducer.xml
%feature("docstring") hfst::HfstTransducer
"""
A synchronous finite-state transducer.
"""
%feature("docstring") hfst::HfstTransducer::get_type
"""
The implementation type of the transducer.
Returns
-------
hfst.ImplementationType
"""
%feature("docstring") hfst::HfstTransducer::get_name
"""
Get the name of the transducer.
See also: set_name
"""
%feature("docstring") hfst::HfstTransducer::repeat_plus
"""
A concatenation of N transducers where N is any number from one to infinity.
"""
%feature("docstring") hfst::HfstTransducer::output_project
"""
Extract the output language of the transducer.
All transition symbol pairs *isymbol:osymbol* are changed to *osymbol:osymbol*.
"""
%feature("docstring") hfst::HfstTransducer::number_of_states
"""
The number of states in the transducer.
"""
%feature("docstring") hfst::HfstTransducer::minus
"""
Alias for subtract.
See also: hfst.HfstTransducer.subtract
"""
%feature("docstring") hfst::HfstTransducer::is_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous.
A transducer is infinitely ambiguous if there exists an input that will yield
infinitely many results, i.e. there are input epsilon loops that are traversed
with that input.
"""
%feature("docstring") hfst::HfstTransducer::eliminate_flags
"""
Eliminate flag diacritics listed in *symbols* from the transducer.
Parameters
----------
* `symbols` :
The flags to be eliminated. TODO: explain more.
An equivalent transducer with no flags listed in *symbols*.
"""
%feature("docstring") hfst::HfstTransducer::longest_path_size
"""
Get length of longest path of the transducer.
"""
%feature("docstring") hfst::HfstTransducer::get_properties
"""
Get all properties from the transducer.
Returns