Example usage for edu.stanford.nlp.dcoref Constants MAXDIST_PROP

List of usage examples for edu.stanford.nlp.dcoref Constants MAXDIST_PROP

Introduction

In this page you can find the example usage for edu.stanford.nlp.dcoref Constants MAXDIST_PROP.

Prototype

String MAXDIST_PROP

To view the source code for edu.stanford.nlp.dcoref Constants MAXDIST_PROP.

Click Source Link

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.stanfordnlp.StanfordCoreferenceResolver.java

License:Open Source License

@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    modelProvider = new ModelProviderBase<Coreferencer>() {
        {/*from   w ww  .  j  ava  2 s.c  o  m*/
            setContextObject(StanfordCoreferenceResolver.this);

            setDefault(ARTIFACT_ID, "${groupId}.stanfordnlp-model-coref-${language}-${variant}");
            setDefault(LOCATION, "classpath:/${package}/lib/coref/${language}/${variant}/countries");
            setDefault(VARIANT, "default");

            // setOverride(LOCATION, modelLocation);
            // setOverride(LANGUAGE, language);
            // setOverride(VARIANT, variant);
        }

        @Override
        protected Coreferencer produceResource(URL aUrl) throws IOException {
            String base = FilenameUtils.getFullPathNoEndSeparator(aUrl.toString()) + "/";

            Properties props = new Properties();
            props.setProperty(Constants.SIEVES_PROP, sieves);
            props.setProperty(Constants.SCORE_PROP, String.valueOf(score));
            props.setProperty(Constants.POSTPROCESSING_PROP, String.valueOf(postprocessing));
            props.setProperty(Constants.SINGLETON_PROP, String.valueOf(singleton));
            props.setProperty(Constants.SINGLETON_MODEL_PROP, base + "singleton.predictor.ser");

            props.setProperty(Constants.MAXDIST_PROP, String.valueOf(maxdist));
            //              props.setProperty(Constants.BIG_GENDER_NUMBER_PROP, "false");
            props.setProperty(Constants.REPLICATECONLL_PROP, "false");
            props.setProperty(Constants.CONLL_SCORER, Constants.conllMentionEvalScript);

            // Cf. edu.stanford.nlp.dcoref.Dictionaries.Dictionaries(Properties)
            // props.getProperty(Constants.DEMONYM_PROP, DefaultPaths.DEFAULT_DCOREF_DEMONYM),
            props.setProperty(Constants.DEMONYM_PROP, base + "demonyms.txt");
            // props.getProperty(Constants.ANIMATE_PROP, DefaultPaths.DEFAULT_DCOREF_ANIMATE),
            props.setProperty(Constants.ANIMATE_PROP, base + "animate.unigrams.txt");
            // props.getProperty(Constants.INANIMATE_PROP, DefaultPaths.DEFAULT_DCOREF_INANIMATE),
            props.setProperty(Constants.INANIMATE_PROP, base + "inanimate.unigrams.txt");
            // props.getProperty(Constants.MALE_PROP),
            props.setProperty(Constants.MALE_PROP, base + "male.unigrams.txt");
            // props.getProperty(Constants.NEUTRAL_PROP),
            props.setProperty(Constants.NEUTRAL_PROP, base + "neutral.unigrams.txt");
            // props.getProperty(Constants.FEMALE_PROP),
            props.setProperty(Constants.FEMALE_PROP, base + "female.unigrams.txt");
            // props.getProperty(Constants.PLURAL_PROP),
            props.setProperty(Constants.PLURAL_PROP, base + "plural.unigrams.txt");
            // props.getProperty(Constants.SINGULAR_PROP),
            props.setProperty(Constants.SINGULAR_PROP, base + "singular.unigrams.txt");
            // props.getProperty(Constants.STATES_PROP, DefaultPaths.DEFAULT_DCOREF_STATES),
            props.setProperty(Constants.STATES_PROP, base + "state-abbreviations.txt");
            // props.getProperty(Constants.GENDER_NUMBER_PROP, DefaultPaths.DEFAULT_DCOREF_GENDER_NUMBER),
            props.setProperty(Constants.GENDER_NUMBER_PROP, base + "gender.map.ser.gz");
            // props.getProperty(Constants.COUNTRIES_PROP, DefaultPaths.DEFAULT_DCOREF_COUNTRIES),
            props.setProperty(Constants.COUNTRIES_PROP, base + "countries");
            // props.getProperty(Constants.STATES_PROVINCES_PROP, DefaultPaths.DEFAULT_DCOREF_STATES_AND_PROVINCES),
            props.setProperty(Constants.STATES_PROVINCES_PROP, base + "statesandprovinces");

            // The following properties are only relevant if the "CorefDictionaryMatch" sieve
            // is enabled.
            // PropertiesUtils.getStringArray(props, Constants.DICT_LIST_PROP,
            //   new String[]{DefaultPaths.DEFAULT_DCOREF_DICT1, DefaultPaths.DEFAULT_DCOREF_DICT2,
            //   DefaultPaths.DEFAULT_DCOREF_DICT3, DefaultPaths.DEFAULT_DCOREF_DICT4}),
            props.put(Constants.DICT_LIST_PROP, '[' + base + "coref.dict1.tsv" + ',' + base + "coref.dict1.tsv"
                    + ',' + base + "coref.dict1.tsv" + ',' + base + "coref.dict1.tsv" + ']');
            // props.getProperty(Constants.DICT_PMI_PROP, DefaultPaths.DEFAULT_DCOREF_DICT1),
            props.put(Constants.DICT_PMI_PROP, base + "coref.dict1.tsv");
            // props.getProperty(Constants.SIGNATURES_PROP, DefaultPaths.DEFAULT_DCOREF_NE_SIGNATURES));
            props.put(Constants.SIGNATURES_PROP, base + "ne.signatures.txt");

            try {
                Coreferencer coref = new Coreferencer();
                coref.corefSystem = new SieveCoreferenceSystem(props);
                coref.mentionExtractor = new MentionExtractor(coref.corefSystem.dictionaries(),
                        coref.corefSystem.semantics());
                return coref;
            } catch (Exception e) {
                throw new IOException(e);
            }
        }
    };
}