forked from stanfordnlp/CoreNLP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpanishTreebankLanguagePack.java
More file actions
139 lines (111 loc) · 3.79 KB
/
SpanishTreebankLanguagePack.java
File metadata and controls
139 lines (111 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package edu.stanford.nlp.trees.international.spanish;
import edu.stanford.nlp.international.spanish.SpanishMorphoFeatureSpecification;
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification;
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.process.TokenizerFactory;
import edu.stanford.nlp.trees.AbstractTreebankLanguagePack;
import edu.stanford.nlp.trees.CollinsHeadFinder;
import edu.stanford.nlp.trees.HeadFinder;
/**
* Language pack for the Spanish treebank.
*
* @author mcdm
*/
public class SpanishTreebankLanguagePack extends AbstractTreebankLanguagePack {
private static final long serialVersionUID = -7059939700276532428L;
//wsg2011: The distributed treebank is encoding in ISO8859_1, but
//the current FrenchTreebankParserParams is currently configured to
//read UTF-8, PTB style trees that have been extracted from the XML
//files.
public static final String FTB_ENCODING = "ISO8859_1";
//The raw treebank uses "PONCT". Change to LDC convention.
private static final String[] frenchPunctTags = {"PUNC"};
private static final String[] frenchSFPunctTags = {"PUNC"};
private static final String[] frenchPunctWords = {"=","*","/","\\","]","[","\"","''", "'", "``", "`", "-LRB-", "-RRB-", "-LCB-", "-RCB-", ".", "?", "!", ",", ":", "-", "--", "...", ";", """};
private static final String[] frenchSFPunctWords = {".", "!", "?"};
private static final char[] annotationIntroducingChars = {'-', '=', '|', '#', '^', '~'};
private static final String[] frenchStartSymbols = {"ROOT"};
@Override
public String getEncoding() {
return FTB_ENCODING;
}
/**
* Returns a String array of punctuation tags for this treebank/language.
*
* @return The punctuation tags
*/
@Override
public String[] punctuationTags() {
return frenchPunctTags;
}
/**
* Returns a String array of punctuation words for this treebank/language.
*
* @return The punctuation words
*/
@Override
public String[] punctuationWords() {
return frenchPunctWords;
}
/**
* Returns a String array of sentence final punctuation tags for this
* treebank/language.
*
* @return The sentence final punctuation tags
*/
@Override
public String[] sentenceFinalPunctuationTags() {
return frenchSFPunctTags;
}
/**
* Returns a String array of sentence final punctuation words for this
* treebank/language.
*
* @return The sentence final punctuation tags
*/
public String[] sentenceFinalPunctuationWords() {
return frenchSFPunctWords;
}
/**
* Return an array of characters at which a String should be
* truncated to give the basic syntactic category of a label.
* The idea here is that French treebank style labels follow a syntactic
* category with various functional and crossreferencing information
* introduced by special characters (such as "NP-SUBJ"). This would
* be truncated to "NP" by the array containing '-'.
*
* @return An array of characters that set off label name suffixes
*/
@Override
public char[] labelAnnotationIntroducingCharacters() {
return annotationIntroducingChars;
}
/**
* Returns a String array of treebank start symbols.
*
* @return The start symbols
*/
@Override
public String[] startSymbols() {
return frenchStartSymbols;
}
/**
* Returns the extension of treebank files for this treebank.
*/
public String treebankFileExtension() {
return "xml";
}
/** {@inheritDoc} */
public HeadFinder headFinder() {
// TODO need custom head finder?
return new CollinsHeadFinder(this);
}
/** {@inheritDoc} */
public HeadFinder typedDependencyHeadFinder() {
return new CollinsHeadFinder(this);
}
@Override
public MorphoFeatureSpecification morphFeatureSpec() {
return new SpanishMorphoFeatureSpecification();
}
}