public DepInst(TextAnnotation annotation) { String[] tokens = annotation.getTokens(); int lenOfTokens = tokens.length; forms = new String[lenOfTokens + 1]; strLemmas = new String[lenOfTokens + 1]; strPos = new String[lenOfTokens + 1]; strChunk = new String[lenOfTokens + 1]; deprels = new String[lenOfTokens + 1]; heads = new int[lenOfTokens + 1]; forms[0] = "<root>"; strLemmas[0] = "<root>"; strPos[0] = "<root-POS>"; strChunk[0] = "<root-CHUNK>"; // Assume that POS and SHALLOW_PARSE Views exist SpanLabelView LemmaView = (SpanLabelView) annotation.getView(ViewNames.LEMMA); SpanLabelView POSView = (SpanLabelView) annotation.getView(ViewNames.POS); SpanLabelView ChunkView = (SpanLabelView) annotation.getView(ViewNames.SHALLOW_PARSE); System.arraycopy(tokens, 0, forms, 1, lenOfTokens); for (int i = 1; i < strLemmas.length; i++) { strLemmas[i] = LemmaView.getLabel(i - 1); strPos[i] = POSView.getLabel(i - 1); strChunk[i] = ChunkView.getLabel(i - 1); } Arrays.fill(deprels, "<no-type>"); Arrays.fill(heads, -1); }
public DepInst(TextAnnotation annotation) { String[] tokens = annotation.getTokens(); int lenOfTokens = tokens.length; forms = new String[lenOfTokens + 1]; strLemmas = new String[lenOfTokens + 1]; strPos = new String[lenOfTokens + 1]; strChunk = new String[lenOfTokens + 1]; deprels = new String[lenOfTokens + 1]; heads = new int[lenOfTokens + 1]; forms[0] = "<root>"; strLemmas[0] = "<root>"; strPos[0] = "<root-POS>"; strChunk[0] = "<root-CHUNK>"; // Assume that POS and SHALLOW_PARSE Views exist SpanLabelView LemmaView = (SpanLabelView) annotation.getView(ViewNames.LEMMA); SpanLabelView POSView = (SpanLabelView) annotation.getView(ViewNames.POS); SpanLabelView ChunkView = (SpanLabelView) annotation.getView(ViewNames.SHALLOW_PARSE); System.arraycopy(tokens, 0, forms, 1, lenOfTokens); for (int i = 1; i < strLemmas.length; i++) { strLemmas[i] = LemmaView.getLabel(i - 1); strPos[i] = POSView.getLabel(i - 1); strChunk[i] = ChunkView.getLabel(i - 1); } Arrays.fill(deprels, "<no-type>"); Arrays.fill(heads, -1); }
String tag = ((SpanLabelView) ta.getView(ViewNames.POS)).getLabel(tokenId);
String tag = ((SpanLabelView) ta.getView(ViewNames.POS)).getLabel(tokenId);
/** * A table is built from a given source corpus file by simply counting the number of times that * each form-POS association appear in a source corpus. * * @param fileName file name of the source corpus * @throws Exception **/ private void buildTableHelper(String fileName) { PennTreebankPOSReader reader = new PennTreebankPOSReader(this.corpusName); reader.readFile(fileName); List<TextAnnotation> tas = reader.getTextAnnotations(); for (TextAnnotation ta : tas) { for (int tokenId = 0; tokenId < ta.size(); tokenId++) { count(ta.getToken(tokenId), ((SpanLabelView) ta.getView(ViewNames.POS)).getLabel(tokenId)); } } }
/** * A table is built from a given source corpus file by simply counting the number of times that * each form-POS association appear in a source corpus. * * @param fileName file name of the source corpus * @throws Exception **/ private void buildTableHelper(String fileName) { PennTreebankPOSReader reader = new PennTreebankPOSReader(this.corpusName); reader.readFile(fileName); List<TextAnnotation> tas = reader.getTextAnnotations(); for (TextAnnotation ta : tas) { for (int tokenId = 0; tokenId < ta.size(); tokenId++) { count(ta.getToken(tokenId), ((SpanLabelView) ta.getView(ViewNames.POS)).getLabel(tokenId)); } } }