Datatypes for rule functions | |
enum | Twol_Type { twol_left, twol_right, twol_both } |
Different types of two-level rules. More... | |
enum | Repl_Type { repl_left, repl_right, repl_up, repl_down } |
Different types of replace rules. More... | |
typedef contexts_t * | ContextsHandle |
A list of transducer pairs. | |
Rule functions | |
ContextsHandle | make_context (TransducerHandle t1, TransducerHandle t2) |
ContextsHandle with a context pair of left context t1 and right context t2. | |
ContextsHandle | append_context (ContextsHandle c1, ContextsHandle c2) |
Add contexts c2 to contexts c1 and return the updated c1. | |
TransducerHandle | make_rule (TransducerHandle t1, KeyPairSet *mappings, Twol_Type type, TransducerHandle t2, KeyPairSet *Pi) |
A transducer that performs mappings defined in KeyPairSet mappings in context defined by transducers t1 and t2 (t1 precedes and t2 follows). Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. Pi defines the alphabet known to the rule. | |
TransducerHandle | make_replace (TransducerHandle t, Repl_Type type, bool optional, KeyPairSet *Pi) |
A replace transducer that performs the mapping t everywhere. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional. | |
TransducerHandle | make_replace_in_context (TransducerHandle t, Repl_Type type, ContextsHandle c, bool optional, KeyPairSet *Pi) |
A replace transducer that performs mapping t in context c. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional. | |
TransducerHandle | make_restriction (TransducerHandle t, Twol_Type type, ContextsHandle c, int direction, KeyPairSet *Pi) |
A restriction transducer that performs the mapping t in all contexts of c. Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. direction defines to which direction mapping can be done. | |
void | delete_contexts_handle (ContextsHandle c) |
Delete ContextsHandle c. |
typedef ContextsHandle ContextsHandle |
A list of transducer pairs.
A transducer pair represents the left and right context in a rule.
Definition at line 46 of file rule-layer.h.
enum Repl_Type |
Different types of replace rules.
Use them with functions make_replace and make_replace_in_context. Their meaning is explained in both functions.
repl_left | Repl_type 'repl_left' |
repl_right | Repl_type 'repl_right' |
repl_up | Repl_type 'repl_up' |
repl_down | Repl_type 'repl_down' |
Definition at line 33 of file rule-layer.h.
enum Twol_Type |
Different types of two-level rules.
Use these with functions make_rule and make_restriction. Their meaning is explained in both functions.
twol_left | Twol_Type 'twol_left' |
twol_right | Twol_Type 'twol_right' |
twol_both | Twol_Type 'twol_both' |
Definition at line 21 of file rule-layer.h.
ContextsHandle append_context | ( | ContextsHandle | c1, | |
ContextsHandle | c2 | |||
) |
Add contexts c2 to contexts c1 and return the updated c1.
void delete_contexts_handle | ( | ContextsHandle | c | ) |
Delete ContextsHandle c.
ContextsHandle c and all transducer pairs listed in c are deleted.
ContextsHandle make_context | ( | TransducerHandle | t1, | |
TransducerHandle | t2 | |||
) |
ContextsHandle with a context pair of left context t1 and right context t2.
t1 | Left context. If NULL, interpreted as an epsilon transducer. | |
t2 | Right context. If NULL, interpreted as an epsilon transducer. |
TransducerHandle make_replace | ( | TransducerHandle | t, | |
Repl_Type | type, | |||
bool | optional, | |||
KeyPairSet * | Pi | |||
) |
A replace transducer that performs the mapping t everywhere. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.
The result is equivalent to expression [~[.* PROJ(t) .*] PROJ(t)]* ~[.* PROJ(t) .*]
, where PROJ(t)
is
t | A transducer defining the mapping. | |
type | The type of replacement rule, 'repl_up' or 'repl_down'. | |
optional | Whether the replacement becomes optional, i.e. whether the resulting transducer is disjuncted with the pi machine [.*] . | |
Pi | The alphabet (set) of key pairs known to the rule |
TransducerHandle make_replace_in_context | ( | TransducerHandle | t, | |
Repl_Type | type, | |||
ContextsHandle | c, | |||
bool | optional, | |||
KeyPairSet * | Pi | |||
) |
A replace transducer that performs mapping t in context c. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.
The value of Repl_Type type defines where matching takes place in the following way:
For example (from Karttunen 1995) the rule defined by transducer {ab}:x
, left context [a b]
and right context [a]
('ab' is mapped to 'x' between 'ab' and 'a') yields the following relations when applied to the input string 'abababa' with different Repl_Types:
Repl_Type: repl_up repl_down repl_left repl_right input level: a b a b a b a a b a b a b a or a b a b a b a a b a b a b a a b a b a b a output level: a b x x a a b x a b a a b a b x a a b a b x a a b x a b a
Alphabet definition can affect the way the resulting transducer works. For instance, the rule defined by transducer_ {aa}:{bb}
, left context [c]
and right context [c]
('aa' is mapped to 'bb' between 'c' and 'c') yields the following relations when applied to the input string 'acaac' with different alphabet definitions:
Alphabet input output(s) a, b and c 'acaac' 'acbbc' a, b, c and a:b 'acaac' 'acabc', 'acbac', 'acbbc', 'bcabc', 'bcbac', 'bcbbc'
t | A transducer defining the mapping. | |
type | The type of replacement rule. | |
c | The context where mapping occurs. | |
optional | Whether the replacement becomes optional, i.e. whether the resulting transducer is disjuncted with the pi machine [.*] . | |
Pi | The alphabet (set) of key pairs known to the rule |
TransducerHandle make_restriction | ( | TransducerHandle | t, | |
Twol_Type | type, | |||
ContextsHandle | c, | |||
int | direction, | |||
KeyPairSet * | Pi | |||
) |
A restriction transducer that performs the mapping t in all contexts of c. Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. direction defines to which direction mapping can be done.
t | Transducer defining the mapping. | |
type | The type of mapping rule.
| |
c | Contexts where mapping can occur. | |
direction | To which direction mapping can be done.
| |
Pi | The alphabet (set) of key pairs known to the rule |
TransducerHandle make_rule | ( | TransducerHandle | t1, | |
KeyPairSet * | mappings, | |||
Twol_Type | type, | |||
TransducerHandle | t2, | |||
KeyPairSet * | Pi | |||
) |
A transducer that performs mappings defined in KeyPairSet mappings in context defined by transducers t1 and t2 (t1 precedes and t2 follows). Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. Pi defines the alphabet known to the rule.
t1 | Left context transducer. | |
mappings | A set of possible key pair mappings that can occur. | |
type | The type of mapping rule.
| |
t2 | Right context transducer. | |
Pi | The alphabet (set) of key pairs known to the rule |
[c]
, mappings = [a:b]
and t2 = [c]
, the resulting transducer yields the following outputs with input string 'acacaca' depending on the value of type:
type input output(s) 'twol_left' 'acacaca' 'acbcbca', 'bcbcbca', 'acbcbcb', 'bcbcbcb' (note that the alphabet must contain the pair a:b here) 'twol_right' 'acacaca' 'acacaca', 'acbcaca', 'acacbca', 'acbcbca' 'twol_both' 'acacaca' 'acbcbca'
More on two-levels rules in Koskenniemi: Two-Level Morphology: A General Computational Model fo Word-Form Recognition and Production (1983).