Skip to content

Commit

Permalink
Tiny cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
manning authored and Stanford NLP committed Feb 7, 2016
1 parent 98edd6f commit 8ad34eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
18 changes: 6 additions & 12 deletions src/edu/stanford/nlp/dcoref/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
package edu.stanford.nlp.dcoref;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

import edu.stanford.nlp.dcoref.Dictionaries.Number;
import edu.stanford.nlp.dcoref.Dictionaries.Person;
Expand Down Expand Up @@ -85,7 +79,7 @@ public List<List<Mention>> getOrderedMentions() {
/** Gold Clusters for coreferent mentions */
public Map<Integer, CorefCluster> goldCorefClusters;

/** All mentions in a document mentionID -> mention*/
/** For all mentions in a document, map mentionID to mention. */
public Map<Integer, Mention> allPredictedMentions;
public Map<Integer, Mention> allGoldMentions;

Expand All @@ -105,7 +99,7 @@ public List<List<Mention>> getOrderedMentions() {
/** List of gold links in a document by positions */
private List<Pair<IntTuple,IntTuple>> goldLinks;

/** UtteranceAnnotation -> String (speaker): mention ID or speaker string */
/** Map UtteranceAnnotation to String (speaker): mention ID or speaker string */
public Map<Integer, String> speakers;

/** Pair of mention id, and the mention's speaker id */
Expand All @@ -118,7 +112,7 @@ public List<List<Mention>> getOrderedMentions() {
/** Set of incompatible clusters pairs */
private TwoDimensionalSet<Integer, Integer> incompatibles;
private TwoDimensionalSet<Integer, Integer> incompatibleClusters;

protected TwoDimensionalMap<Integer, Integer, Boolean> acronymCache;

/** Map of speaker name/id to speaker info */
Expand All @@ -136,7 +130,7 @@ public Document() {
speakerPairs = Generics.newHashSet();
incompatibles = TwoDimensionalSet.hashSet();
incompatibleClusters = TwoDimensionalSet.hashSet();
acronymCache = TwoDimensionalMap.hashMap();
acronymCache = TwoDimensionalMap.hashMap();
}

public Document(Annotation anno, List<List<Mention>> predictedMentions,
Expand Down Expand Up @@ -250,7 +244,7 @@ private void initializeCorefCluster() {
m.sentNum = i;

assert(!corefClusters.containsKey(m.mentionID));
corefClusters.put(m.mentionID, new CorefCluster(m.mentionID, Generics.newHashSet(Arrays.asList(m))));
corefClusters.put(m.mentionID, new CorefCluster(m.mentionID, Generics.newHashSet(Collections.singletonList(m))));
m.corefClusterID = m.mentionID;

IntTuple headPosition = new IntTuple(2);
Expand Down
9 changes: 4 additions & 5 deletions src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import edu.stanford.nlp.dcoref.ScorerBCubed.BCubedType;
import edu.stanford.nlp.dcoref.sievepasses.DeterministicCorefSieve;
import edu.stanford.nlp.dcoref.sievepasses.ExactStringMatch;
import edu.stanford.nlp.hcoref.data.*;
import edu.stanford.nlp.io.IOUtils;
import edu.stanford.nlp.io.RuntimeIOException;
import edu.stanford.nlp.io.StringOutputStream;
Expand Down Expand Up @@ -378,8 +377,8 @@ public static String initializeAndRunCoref(Properties props) throws Exception {
SieveCoreferenceSystem corefSystem = new SieveCoreferenceSystem(props);

// MentionExtractor extracts MUC, ACE, or CoNLL documents
MentionExtractor mentionExtractor = null;
if(props.containsKey(Constants.MUC_PROP)){
MentionExtractor mentionExtractor;
if (props.containsKey(Constants.MUC_PROP)){
mentionExtractor = new MUCMentionExtractor(corefSystem.dictionaries, props,
corefSystem.semantics, corefSystem.singletonPredictor);
} else if(props.containsKey(Constants.ACE2004_PROP) || props.containsKey(Constants.ACE2005_PROP)) {
Expand All @@ -388,10 +387,10 @@ public static String initializeAndRunCoref(Properties props) throws Exception {
} else if (props.containsKey(Constants.CONLL2011_PROP)) {
mentionExtractor = new CoNLLMentionExtractor(corefSystem.dictionaries, props,
corefSystem.semantics, corefSystem.singletonPredictor);
}
if(mentionExtractor == null){
} else {
throw new RuntimeException("No input file specified!");
}

if (!Constants.USE_GOLD_MENTIONS) {
// Set mention finder
String mentionFinderClass = props.getProperty(Constants.MENTION_FINDER_PROP);
Expand Down
7 changes: 6 additions & 1 deletion src/edu/stanford/nlp/dcoref/util/ConvertGenderFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
* etc <br>
* <br>
* into a serialized data structure which should take much less time to load.
*
* @author John Bauer
*/
public class ConvertGenderFile {

private ConvertGenderFile() {} // static class

public static void main(String[] args) throws IOException {
String input = null;
String output = null;
Expand Down Expand Up @@ -47,7 +52,7 @@ public static void main(String[] args) throws IOException {
for (String line; (line = reader.readLine()) != null; ) {
String[] split = line.split("\t");
String[] countStr = split[1].split(" ");

int male = Integer.parseInt(countStr[0]);
int female = Integer.parseInt(countStr[1]);
int neutral = Integer.parseInt(countStr[2]);
Expand Down

0 comments on commit 8ad34eb

Please sign in to comment.