TWiki> FST Web>FstQuickTour>ArcMapDoc (revision 7)EditAttach

# Map

## Description

This operation transforms each arc and final state in the input FST. The transformation is specified by a function object called a mapper.

For instance, `RmWeightMapper` replaces the weight of every arc and final state by 1.

A list of available mappers and instructions on how to create them are given here.

## Usage

 ```template Map(MutableFst *fst, Mapper *mapper); ``` [bad link?] ```template Map(MutableFst *fst, Mapper mapper); ``` ```template Map(const Fst &ifst, MutableFst *ofst, Mapper *mapper); ``` ```template Map(const Fst &ifst, MutableFst *ofst, Mapper mapper); ``` ```template MapFst:: MapFst(const Fst &fst, Mapper *mapper); ``` ```template MapFst:: MapFst(const Fst &fst, const Mapper &mapper); ``` ```fstmap [--opts] in.fst out.fst -delta (Comparison/quantization delta) type: double default: 0.0009765625 -map_type (Map operation, one of: "identity", "invert", "plus (--weight)", "quantize (--delta)", "rmweight", "superfinal", "times (--weight)" ) type: string default: "identity" -weight (Weight parameter) type: string default: "" ```

## Example

### `Map(&A, RmWeightMapper())`:

```Map(&A, RmWeightMapper<StdArc>());
Map(A, &B, RmWeightMapper<StdArc>());
MapFst B(A, RmWeightMapper<StdArc>());

fstmap --map_type=rmweight a.fst b.fst
```

## Complexity

`Map:`

• Time: O(c*(V + E))
• Space: O(m)
where V = # of states, E = # of arcs in input FST, c = cost of processing one arc by the mapper and m = total memory usage for the mapper.

`MapFst:`

• Time: O(c*(v + e))
• Space: O(m)
where v = # of visited states, e = # of visited arcs in input FST, c = cost of processing one arc by the mapper and m = total memory usage for the mapper. Constant time and space to visit an input state or arc is assumed and exclusive of caching.

For instance in the case of `RmWeightMapper`, we have c = O(1) and m = O(1).

-- CyrilAllauzen - 04 Mar 2009

Topic attachments
I Attachment History Action Size Date Who Comment
png map1.png r1 manage 19.1 K 2009-03-17 - 19:13 CyrilAllauzen Map example: input FST
png map2.png r1 manage 18.2 K 2009-03-17 - 19:13 CyrilAllauzen Map example: output FST
Edit | Attach | Watch | Print version |  | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r7 - 2011-04-12 - AntoineAmarilli

Copyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback