for(int i = 0; i<ls.size(); i++){ instances.get(i).predictedCategory=ls.get(i).toString(); categList.add(ls.get(i).toString());
@Override public BibEntry parseBibReference(String text) throws AnalysisException { try { Citation citation = CitationUtils.stringToCitation(text); String data = StringUtils.join(CitationUtils.citationToMalletInputFormat(citation), "\n"); ACRF model = readModel(); Pipe pipe = model.getInputPipe(); InstanceList instanceList = new InstanceList(pipe); instanceList.add(new LineGroupIterator(new StringReader(data), Pattern.compile ("\\s*"), true)); LabelsSequence labelSequence = (LabelsSequence)model.getBestLabels(instanceList).get(0); for (int i = 0; i < labelSequence.size(); i++) { citation.getTokens().get(i).setLabel(CitationTokenLabel.valueOf(labelSequence.get(i).toString())); } return CitationUtils.citationToBibref(citation); } catch (ClassNotFoundException ex) { throw new AnalysisException("Cannot parse reference", ex); } catch (IOException ex) { throw new AnalysisException("Cannot parse reference", ex); } }
public void testSerializable () throws IOException, ClassNotFoundException { LabelAlphabet dict = new LabelAlphabet (); Labels lbls1 = new Labels (new Label[] { dict.lookupLabel ("A"), dict.lookupLabel ("B"), }); Labels lbls2 = new Labels (new Label[] { dict.lookupLabel ("C"), dict.lookupLabel ("A"), }); LabelsSequence lblseq = new LabelsSequence (new Labels[] { lbls1, lbls2 }); LabelsSequence lblseq2 = (LabelsSequence) TestSerializable.cloneViaSerialization (lblseq); assertEquals (lblseq.size(), lblseq2.size()); assertEquals (lblseq.getLabels(0).toString(), lblseq2.getLabels(0).toString ()); assertEquals (lblseq.getLabels(1).toString(), lblseq2.getLabels(1).toString ()); }