Cambridge SMT System
RuleData.java
Go to the documentation of this file.
1 /*******************************************************************************
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use these files except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  *
14  * Copyright 2014 - Juan Pino, Aurelien Waite, William Byrne
15  *******************************************************************************/
16 
17 package uk.ac.cam.eng.extraction.hadoop.datatypes;
18 
19 import java.io.DataInput;
20 import java.io.DataOutput;
21 import java.io.IOException;
22 
23 import org.apache.hadoop.io.Writable;
24 
25 
34 public class RuleData implements Writable {
35 
36  private ProvenanceCountMap provCounts;
37 
38  private AlignmentCountMapWritable alignments;
39 
40  private FeatureMap features;
41 
45  public static final RuleData EMPTY = new RuleData(new ProvenanceCountMap(),
47 
48  public RuleData() {
49  provCounts = new ProvenanceCountMap();
50  alignments = new AlignmentCountMapWritable();
51  features = new FeatureMap();
52  }
53 
54  public RuleData(RuleData other){
55  this.provCounts = new ProvenanceCountMap(other.provCounts);
56  this.alignments = new AlignmentCountMapWritable(other.alignments);
57  this.features = new FeatureMap(other.features);
58  }
59 
60  public RuleData(ProvenanceCountMap provCounts, AlignmentCountMapWritable alignments,
61  FeatureMap features) {
62  this.provCounts = provCounts;
63  this.alignments = alignments;
64  this.features = features;
65  }
66 
67  public void clear() {
68  provCounts.clear();
69  alignments.clear();
70  features.clear();
71  }
72 
73  public void merge(RuleData other) {
74  provCounts.putAll(other.provCounts);
75  features.merge(other.features);
76  alignments.merge(other.alignments);
77  }
78 
79  @Override
80  public void readFields(DataInput in) throws IOException {
81  provCounts.readFields(in);
82  features.readFields(in);
83  alignments.readFields(in);
84  }
85 
86  @Override
87  public void write(DataOutput out) throws IOException {
88  provCounts.write(out);
89  features.write(out);
90  alignments.write(out);
91  }
92 
93 
99  return provCounts;
100  }
101 
108  return alignments;
109  }
110 
116  return features;
117  }
118 
119  public void setProvCounts(ProvenanceCountMap provCounts) {
120  this.provCounts = provCounts;
121  }
122 
123  public void setAlignments(AlignmentCountMapWritable alignments) {
124  this.alignments = alignments;
125  }
126 
127  public void setFeatures(FeatureMap features) {
128  this.features = features;
129  }
130 
131  @Override
132  public String toString() {
133  return "RuleData [provCounts=" + provCounts + ", alignments="
134  + alignments + ", features=" + features + "]";
135  }
136 
137 
138 }
void setAlignments(AlignmentCountMapWritable alignments)
Definition: RuleData.java:123
RuleData(ProvenanceCountMap provCounts, AlignmentCountMapWritable alignments, FeatureMap features)
Definition: RuleData.java:60
void putAll(Map<?extends ByteWritable,?extends IntWritable > m)
void setProvCounts(ProvenanceCountMap provCounts)
Definition: RuleData.java:119