transducer

Finite State Transducers in Haskell?

强颜欢笑 提交于 2019-11-30 12:11:06
问题 I've been wondering if there is a way to define and work with finite state transducers in Haskell in an idiomatic way. You can approach FSTs as generators (it generates an output of type {x1,x2}), or as recognizers (given an input of type {x1,x2} it recognizes it if it belongs to the rational relation), or as translators (given an input tape, it translates it into an output tape). Would the representation change depending on the approach? Would it also be possible to model a FST in a way that

How to parse a DOT file in Python

无人久伴 提交于 2019-11-30 06:49:13
问题 I have a transducer saved in the form of a DOT file. I can see a graphical representation of the graphs using gvedit, but what if I want to convert the DOT file to an executable transducer, so that I can test the transducer and see what strings it accepts and what it doesn't. In most of the tools I have seen in Openfst, Graphviz, and their Python extensions, DOT files are only used to create a graphical representation, but what if I want to parse the file to get an interactive program where I

Clojure transducers behavior

蹲街弑〆低调 提交于 2019-11-28 23:41:04
With new clojure 1.7 I decided to understand where I can use transducers. I understand what benefit they can give, but I can't find normal examples of writing custom transducers with explanation. Ok, I tried to test what is happening. I opened the clojure documentation. And there examples use xf as argument. First: what means this xf or xfrom? This stuff produced identity transducer. (defn my-identity [xf] (fn ([] (println "Arity 0.") (xf)) ([result] (println "Arity 1: " result " = " (xf result)) (xf result)) ([result input] (println "Arity 2: " result input " = " (xf result input)) (xf result

Clojure transducers behavior

霸气de小男生 提交于 2019-11-27 21:19:43
问题 With new clojure 1.7 I decided to understand where I can use transducers. I understand what benefit they can give, but I can't find normal examples of writing custom transducers with explanation. Ok, I tried to test what is happening. I opened the clojure documentation. And there examples use xf as argument. First: what means this xf or xfrom? This stuff produced identity transducer. (defn my-identity [xf] (fn ([] (println "Arity 0.") (xf)) ([result] (println "Arity 1: " result " = " (xf

Can someone explain Clojure Transducers to me in Simple terms?

血红的双手。 提交于 2019-11-27 16:56:47
I have tried reading up on this but I still don't understand the value of them or what they replace. And do they make my code shorter, more understandable or what? Update Alot of people posted answers, but it would be nice to see examples of with and without transducers for something very simple, which even an idiot like me can understand. Unless of course transducers need a certain high level of understanding, in which case I will never understand them :( Transducers are recipes what to do with a sequence of data without knowledge what the underlying sequence is (how to do it). It can be any

Can someone explain Clojure Transducers to me in Simple terms?

≯℡__Kan透↙ 提交于 2019-11-26 18:48:22
问题 I have tried reading up on this but I still don't understand the value of them or what they replace. And do they make my code shorter, more understandable or what? Update Alot of people posted answers, but it would be nice to see examples of with and without transducers for something very simple, which even an idiot like me can understand. Unless of course transducers need a certain high level of understanding, in which case I will never understand them :( 回答1: Transducers are recipes what to