1 package net.sf.okapi.steps.heuristicaligner;
2
3 import net.sf.okapi.common.EditorFor;
4 import net.sf.okapi.common.ParametersDescription;
5 import net.sf.okapi.common.StringParameters;
6 import net.sf.okapi.common.uidescription.EditorDescription;
7 import net.sf.okapi.common.uidescription.IEditorDescriptionProvider;
8
9 @EditorFor(HeuristicSentenceAlignerParameters.class)
10 public class HeuristicSentenceAlignerParameters extends StringParameters implements IEditorDescriptionProvider {
11
12 private static final String SEGMENT_SOURCE = "segmentSource";
13 private static final String SEGMENT_TARGET = "segmentTarget";
14 private static final String USE_CUSTOM_SOURCE_RULES = "useCustomSourceRules";
15 private static final String USE_CUSTOM_TARGET_RULES = "useCustomTargetRules";
16 private static final String CUSTOM_SOURCE_RULES_PATH = "customSourceRulesPath";
17 private static final String CUSTOM_TARGET_RULES_PATH = "customTargetRulesPath";
18 private static final String COLLAPSE_WHITESPACE = "collapseWhitespace";
19 private static final String FORCE_SIMPLE_ONE_TO_ONE_ALIGNMENT = "forceSimpleOneToOneAlignment";
20
21 public HeuristicSentenceAlignerParameters() {
22 super();
23 }
24
25 public boolean isSegmentSource() {
26 return getBoolean(SEGMENT_SOURCE);
27 }
28
29 public void setSegmentSource(boolean segmentSource) {
30 setBoolean(SEGMENT_SOURCE, segmentSource);
31 }
32
33 public boolean isSegmentTarget() {
34 return getBoolean(SEGMENT_TARGET);
35 }
36
37 public void setSegmentTarget(boolean segmentTarget) {
38 setBoolean(SEGMENT_TARGET, segmentTarget);
39 }
40
41 public boolean isUseCustomSourceRules() {
42 return getBoolean(USE_CUSTOM_SOURCE_RULES);
43 }
44
45 public void setUseCustomSourceRules(boolean useCustomSourceRules) {
46 setBoolean(USE_CUSTOM_SOURCE_RULES, useCustomSourceRules);
47 }
48
49 public boolean isUseCustomTargetRules() {
50 return getBoolean(USE_CUSTOM_TARGET_RULES);
51 }
52
53 public void setUseCustomTargetRules(boolean useCustomTargetRules) {
54 setBoolean(USE_CUSTOM_TARGET_RULES, useCustomTargetRules);
55 }
56
57 public String getCustomSourceRulesPath() {
58 return getString(CUSTOM_SOURCE_RULES_PATH);
59 }
60
61 public void setCustomSourceRulesPath(String customSourceRulesPath) {
62 setString(CUSTOM_SOURCE_RULES_PATH, customSourceRulesPath);
63 }
64
65 public String getCustomTargetRulesPath() {
66 return getString(CUSTOM_TARGET_RULES_PATH);
67 }
68
69 public void setCustomTargetRulesPath(String customTargetRulesPath) {
70 setString(CUSTOM_TARGET_RULES_PATH, customTargetRulesPath);
71 }
72
73 public boolean isCollapseWhitespace() {
74 return getBoolean(COLLAPSE_WHITESPACE);
75 }
76
77 public void setCollapseWhitespace(boolean collapseWhitespace) {
78 setBoolean(COLLAPSE_WHITESPACE, collapseWhitespace);
79 }
80
81 public boolean isForceSimpleOneToOneAlignment() {
82 return getBoolean(FORCE_SIMPLE_ONE_TO_ONE_ALIGNMENT);
83 }
84
85 public void setForceSimpleOneToOneAlignment(boolean forceSimpleOneToOneAlignment) {
86 setBoolean(FORCE_SIMPLE_ONE_TO_ONE_ALIGNMENT, forceSimpleOneToOneAlignment);
87 }
88
89 @Override
90 public void reset() {
91 super.reset();
92 setSegmentSource(true);
93 setSegmentTarget(true);
94 setUseCustomSourceRules(false);
95 setUseCustomTargetRules(false);
96 setCustomSourceRulesPath("");
97 setCustomTargetRulesPath("");
98 setCollapseWhitespace(true);
99 setForceSimpleOneToOneAlignment(false);
100 }
101
102 @Override
103 public ParametersDescription getParametersDescription() {
104 ParametersDescription desc = new ParametersDescription(this);
105 desc.add(SEGMENT_SOURCE, "Segment source", "Enable source segmentation");
106 desc.add(SEGMENT_TARGET, "Segment target", "Enable target segmentation");
107 desc.add(USE_CUSTOM_SOURCE_RULES, "Use custom source rules", "Use custom SRX rules for source");
108 desc.add(USE_CUSTOM_TARGET_RULES, "Use custom target rules", "Use custom SRX rules for target");
109 desc.add(CUSTOM_SOURCE_RULES_PATH, "Custom source rules path", "Path to custom SRX file for source");
110 desc.add(CUSTOM_TARGET_RULES_PATH, "Custom target rules path", "Path to custom SRX file for target");
111 desc.add(COLLAPSE_WHITESPACE, "Collapse whitespace", "Collapse multiple whitespace to single space");
112 desc.add(FORCE_SIMPLE_ONE_TO_ONE_ALIGNMENT, "Force 1:1 alignment",
113 "Force simple 1:1 paragraph alignment when counts match");
114 return desc;
115 }
116
117 @Override
118 public EditorDescription createEditorDescription(ParametersDescription paramDesc) {
119 EditorDescription desc = new EditorDescription("Heuristic Sentence Aligner", true, false);
120
121 desc.addCheckboxPart(paramDesc.get(SEGMENT_SOURCE));
122 desc.addCheckboxPart(paramDesc.get(SEGMENT_TARGET));
123 desc.addCheckboxPart(paramDesc.get(USE_CUSTOM_SOURCE_RULES));
124 desc.addTextInputPart(paramDesc.get(CUSTOM_SOURCE_RULES_PATH));
125 desc.addCheckboxPart(paramDesc.get(USE_CUSTOM_TARGET_RULES));
126 desc.addTextInputPart(paramDesc.get(CUSTOM_TARGET_RULES_PATH));
127 desc.addCheckboxPart(paramDesc.get(COLLAPSE_WHITESPACE));
128 desc.addCheckboxPart(paramDesc.get(FORCE_SIMPLE_ONE_TO_ONE_ALIGNMENT));
129
130 return desc;
131 }
132 }