Skip to content

Commit 06e4677

Browse files
committed
Consolidate VariableStrings into one location - the two were almost exact copies of each other
1 parent 79fee94 commit 06e4677

File tree

7 files changed

+14
-53
lines changed

7 files changed

+14
-53
lines changed

src/edu/stanford/nlp/semgraph/semgrex/CoordinationPattern.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import edu.stanford.nlp.ling.IndexedWord;
77
import edu.stanford.nlp.semgraph.SemanticGraph;
88
import edu.stanford.nlp.semgraph.SemanticGraphEdge;
9+
import edu.stanford.nlp.trees.tregex.VariableStrings;
910

1011
/** @author Chloe Kiddon */
1112
public class CoordinationPattern extends SemgrexPattern {

src/edu/stanford/nlp/semgraph/semgrex/NodePattern.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import edu.stanford.nlp.ling.IndexedWord;
1313
import edu.stanford.nlp.semgraph.SemanticGraph;
1414
import edu.stanford.nlp.semgraph.SemanticGraphEdge;
15+
import edu.stanford.nlp.trees.tregex.VariableStrings;
1516
import edu.stanford.nlp.util.Pair;
1617
import edu.stanford.nlp.util.Quadruple;
1718
import edu.stanford.nlp.util.Triple;

src/edu/stanford/nlp/semgraph/semgrex/SemgrexMatcher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import edu.stanford.nlp.graph.CyclicGraphException;
44
import edu.stanford.nlp.semgraph.SemanticGraph;
55
import edu.stanford.nlp.semgraph.SemanticGraphEdge;
6+
import edu.stanford.nlp.trees.tregex.VariableStrings;
67
import edu.stanford.nlp.ling.*;
78
import edu.stanford.nlp.util.logging.Redwood;
89

src/edu/stanford/nlp/semgraph/semgrex/SemgrexPattern.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import edu.stanford.nlp.trees.MemoryTreebank;
1717
import edu.stanford.nlp.trees.Tree;
1818
import edu.stanford.nlp.trees.TreeNormalizer;
19+
import edu.stanford.nlp.trees.tregex.VariableStrings;
1920
import edu.stanford.nlp.trees.ud.CoNLLUDocumentWriter;
2021
import edu.stanford.nlp.util.ArrayCoreMap;
2122
import edu.stanford.nlp.util.CoreMap;

src/edu/stanford/nlp/semgraph/semgrex/VariableStrings.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/edu/stanford/nlp/stats/IntCounter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public IntCounter(MapFactory<E,MutableInteger> mapFactory) {
7373
* Constructs a new Counter with the contents of the given Counter.
7474
*/
7575
public IntCounter(IntCounter<E> c) {
76-
this();
76+
this(c.mapFactory);
7777
addAll(c);
7878
}
7979

src/edu/stanford/nlp/trees/tregex/VariableStrings.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import java.util.Map;
99

1010
/** A class that takes care of the stuff necessary for variable strings.
11+
*
12+
*<br>
13+
* TODO: move this to util?
1114
*
1215
* @author Roger Levy ([email protected])
1316
*/
14-
class VariableStrings {
15-
17+
public class VariableStrings {
1618
private final Map<String, String> varsToStrings;
1719
private final IntCounter<String> numVarsSet;
1820

@@ -21,6 +23,11 @@ public VariableStrings() {
2123
numVarsSet = new IntCounter<>(MapFactory.<String, MutableInteger>arrayMapFactory());
2224
}
2325

26+
public VariableStrings(VariableStrings other) {
27+
varsToStrings = new ArrayMap<>(other.varsToStrings);
28+
numVarsSet = new IntCounter<>(other.numVarsSet);
29+
}
30+
2431
public void reset() {
2532
numVarsSet.clear();
2633
varsToStrings.clear();

0 commit comments

Comments
 (0)