当前位置: 首页>>代码示例>>Java>>正文


Java StringArray.set方法代码示例

本文整理汇总了Java中org.apache.uima.jcas.cas.StringArray.set方法的典型用法代码示例。如果您正苦于以下问题:Java StringArray.set方法的具体用法?Java StringArray.set怎么用?Java StringArray.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.jcas.cas.StringArray的用法示例。


在下文中一共展示了StringArray.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readCast

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
public static void readCast(JCas jcas, Drama drama, Document doc) {
	Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
	Elements castEntries = doc.select("profileDesc > particDesc > listPerson > person");
	// castEntries.addAll(doc.select("profileDesc > particDesc > listPerson
	// > personGrp"));
	FSArray castListArray = new FSArray(jcas, castEntries.size());
	for (int i = 0; i < castEntries.size(); i++) {
		Element castEntry = castEntries.get(i);
		String id = castEntry.attr("xml:id");
		StringArray arr = new StringArray(jcas, 1);
		arr.set(0, castEntry.text());
		CastFigure figure = new CastFigure(jcas);
		figure.setXmlId(id);
		figure.setNames(arr);
		idFigureMap.put(id, figure);
		castListArray.set(i, figure);
	}
	drama.setCastList(castListArray);

	for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
		speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
		for (int i = 0; i < speaker.getXmlId().size(); i++)
			speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:26,代码来源:CoreTEIUrlReader.java

示例2: readCast

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
private static void readCast(JCas jcas, Drama drama, Document doc) {
	Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
	Elements castEntries = doc.select("castList > castItem > role");
	// castEntries.addAll(doc.select("profileDesc > particDesc > listPerson
	// > personGrp"));
	FSArray castListArray = new FSArray(jcas, castEntries.size());
	for (int i = 0; i < castEntries.size(); i++) {
		Element castEntry = castEntries.get(i);
		String id = castEntry.attr("xml:id");
		StringArray arr = new StringArray(jcas, 1);
		arr.set(0, castEntry.text());
		CastFigure figure = new CastFigure(jcas);
		figure.setXmlId(id);
		figure.setNames(arr);
		idFigureMap.put(id, figure);
		castListArray.set(i, figure);
	}
	drama.setCastList(castListArray);

	for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
		speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
		for (int i = 0; i < speaker.getXmlId().size(); i++)
			speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:26,代码来源:TheatreClassicUrlReader.java

示例3: testStringArray

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
@Test
public void testStringArray(){
	DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
	StringArray rel = new StringArray(jCas, 3);
	rel.set(0, "ENG");
	rel.set(1, "WAL");
	rel.set(2, "SCO");
	da.setDocumentReleasability(rel);
	
	Feature f = da.getType().getFeatureByBaseName(DOCUMENT_RELEASABILITY);
	
	Object[] o = FeatureUtils.featureToArray(f, da);
	assertEquals(3, o.length);
	assertTrue(o[0] instanceof String);
	assertEquals("ENG", (String)o[0]);
	assertTrue(o[1] instanceof String);
	assertEquals("WAL", (String)o[1]);
	assertTrue(o[2] instanceof String);
	assertEquals("SCO", (String)o[2]);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:21,代码来源:FeatureUtilsTest.java

示例4: testStringArrayToObject

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
@Test
public void testStringArrayToObject(){
	DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
	StringArray rel = new StringArray(jCas, 3);
	rel.set(0, "true");
	rel.set(1, "2");
	rel.set(2, "0.45");
	da.setDocumentReleasability(rel);
	
	Feature f = da.getType().getFeatureByBaseName(DOCUMENT_RELEASABILITY);
	
	Object[] o = FeatureUtils.featureToArray(f, da);
	assertEquals(3, o.length);
	assertTrue(o[0] instanceof Boolean);
	assertTrue((Boolean)o[0]);
	assertTrue(o[1] instanceof Integer);
	assertEquals(new Integer(2), (Integer)o[1]);
	assertTrue(o[2] instanceof Double);
	assertEquals(new Double(0.45), (Double)o[2]);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:21,代码来源:FeatureUtilsTest.java

示例5: testStringArrayToList

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
@Test
public void testStringArrayToList(){
	DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
	StringArray rel = new StringArray(jCas, 3);
	rel.set(0, "ENG");
	rel.set(1, "WAL");
	rel.set(2, "SCO");
	da.setDocumentReleasability(rel);
	
	Feature f = da.getType().getFeatureByBaseName(DOCUMENT_RELEASABILITY);
	
	List<Object> o = FeatureUtils.featureToList(f, da);
	assertEquals(3, o.size());
	assertTrue(o.get(0) instanceof String);
	assertEquals("ENG", (String)o.get(0));
	assertTrue(o.get(1) instanceof String);
	assertEquals("WAL", (String)o.get(1));
	assertTrue(o.get(2) instanceof String);
	assertEquals("SCO", (String)o.get(2));
}
 
开发者ID:dstl,项目名称:baleen,代码行数:21,代码来源:FeatureUtilsTest.java

示例6: readFieldFromDb

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
public static void readFieldFromDb(String fieldKey, String range,
        Annotation a, Feature f, BasicDBObject dbO, JCas jCas) {

    if (dbO.containsField(fieldKey)) {

        if (range.equals("String")) {
            a.setStringValue(f, dbO.getString(fieldKey));
        } else if (range.equals("StringArray")) {
            BasicDBList vals = (BasicDBList) dbO.get(fieldKey);
            StringArray sa = new StringArray(jCas, vals.size());
            for (int i = 0; i < vals.size(); i++) {
                sa.set(i, vals.get(i).toString());
            }
            a.setFeatureValue(f, sa);
        } else if (range.equals("Integer")) {
            a.setIntValue(f, dbO.getInt(fieldKey));
        } else if (range.equals("Float")) {
            a.setFloatValue(f, (float) dbO.getDouble(fieldKey));
        } else if (range.equals("Boolean")) {
            a.setBooleanValue(f, dbO.getBoolean(fieldKey));
        } else {
            LOG.warn("range not supported " + range);
        }
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:26,代码来源:MongoFieldMapping.java

示例7: setSlotValues

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
public void setSlotValues(Collection<String> slotValues) throws InvalidInputException {
	List<String> slotValuesList = new ArrayList<String>(slotValues);
	StringArray stringArray = new StringArray(jcas, slotValues.size());
	for (int i = 0; i < slotValues.size(); i++) {
		stringArray.set(i, slotValuesList.get(i));
	}
	wrappedSM.setSlotValues(stringArray);
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:9,代码来源:WrappedCCPStringSlotMention.java

示例8: initializeStringSlotMention

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
/**
 * Initializes a new CCPStringSlotMention
 * 
 * @param slotMentionName
 * @param slotValue
 * @param jcas
 * @return
 */
private static CCPStringSlotMention initializeStringSlotMention(String slotMentionName,
		Collection<String> slotValues, JCas jcas) {
	StringArray slotValuesArray = new StringArray(jcas, slotValues.size());
	int index = 0;
	for (String slotValue : slotValues) {
		slotValuesArray.set(index++, slotValue);
	}

	CCPStringSlotMention ccpSSM = new CCPStringSlotMention(jcas);
	ccpSSM.setSlotValues(slotValuesArray);
	ccpSSM.setMentionName(slotMentionName);
	return ccpSSM;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:22,代码来源:CCPPrimitiveSlotMentionFactory.java

示例9: readCast

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
private static void readCast(JCas jcas, Drama drama, Document doc) {
	Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
	Elements castEntries = doc.select("profileDesc > particDesc > listPerson > person");
	castEntries.addAll(doc.select("profileDesc > particDesc > listPerson > personGrp"));
	FSArray castListArray = new FSArray(jcas, castEntries.size());
	for (int i = 0; i < castEntries.size(); i++) {
		Element castEntry = castEntries.get(i);
		String id = castEntry.attr("xml:id");
		Elements nameElements = castEntry.select("persName");
		StringArray arr = new StringArray(jcas, nameElements.size());
		for (int j = 0; j < nameElements.size(); j++) {
			arr.set(j, nameElements.get(j).text());
		}
		CastFigure figure = new CastFigure(jcas);
		figure.setXmlId(id);
		figure.setNames(arr);
		idFigureMap.put(id, figure);
		castListArray.set(i, figure);
	}
	drama.setCastList(castListArray);

	for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
		speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
		for (int i = 0; i < speaker.getXmlId().size(); i++)
			speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:28,代码来源:GerDraCorUrlReader.java

示例10: toStringArray

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
public static StringArray toStringArray(JCas cas, Collection<String> srcCol) {
    StringArray result = new StringArray(cas, srcCol.size());
    int i = 0;
    for (String gr : srcCol) {
        result.set(i, gr);
        i++;
    }
    return result;
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:10,代码来源:FSUtils.java

示例11: listToStringArray

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
private StringArray listToStringArray(JCas jCas, List<Object> l) {
	StringArray sa = new StringArray(jCas, l.size());

	int index = 0;
	for (Object o : l) {
		sa.set(index, o.toString());
		index++;
	}

	return sa;
}
 
开发者ID:dstl,项目名称:baleen,代码行数:12,代码来源:AbstractAhoCorasickAnnotator.java

示例12: testNull

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
@Test
public void testNull(){
	DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
	StringArray rel = new StringArray(jCas, 3);
	rel.set(0, "ENG");
	rel.set(1, "WAL");
	rel.set(2, "SCO");
	da.setDocumentReleasability(rel);
	
	Feature f = da.getType().getFeatureByBaseName(DOCUMENT_RELEASABILITY);
	
	Object o = FeatureUtils.featureToObject(f, da);
	assertNull(o);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:15,代码来源:FeatureUtilsTest.java

示例13: testUimaToJava

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
@Test
public void testUimaToJava() {
	StringArray sa = new StringArray(jCas, 3);
	sa.set(0, "Foo");
	sa.set(1, "Bar");
	sa.set(2, "Baz");

	String[] s = UimaTypesUtils.toArray(sa);
	assertEquals(3, s.length);
	assertEquals("Foo", s[0]);
	assertEquals("Bar", s[1]);
	assertEquals("Baz", s[2]);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:14,代码来源:UimaTypesUtilsTest.java

示例14: addOccurrenceToCas

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
private void addOccurrenceToCas(JCas jCas, RegexOccurrence occurrence) {
	TermOccAnnotation annotation = (TermOccAnnotation) jCas
			.getCas().createAnnotation(
					jCas.getCasType(TermOccAnnotation.type),
					occurrence.getBegin(),
					occurrence.getEnd());
	
	StringArray patternFeature = new StringArray(jCas, occurrence.size());
	FSArray innerWords = new FSArray(jCas, occurrence.size());
	StringBuilder termLemma = new StringBuilder();
	int i = 0;
	for (LabelledAnnotation la:occurrence.getLabelledAnnotations()) {
		patternFeature.set(i, la.getLabel());
		WordAnnotation word = (WordAnnotation) la.getAnnotation();
		termLemma.append(word.getLemma());
		if(i<occurrence.size()-1)
			termLemma.append(TermSuiteConstants.WHITESPACE);
		WordAnnotation wordAnno = (WordAnnotation) la.getAnnotation();
		if(wordAnno.getRegexLabel() != null) {
			if(!wordAnno.getRegexLabel().equals(la.getLabel())) {
				LOGGER.warn("Another label has already been set for WordAnnotation "+wordAnno.getCoveredText()+":"+wordAnno.getRegexLabel()+" ["+wordAnno.getBegin()+","+wordAnno.getEnd()+"]. Ignoring the new label "+la.getLabel()+" (rule: "+occurrence.getRule().getName()+")");
			}
		} else
			wordAnno.setRegexLabel(la.getLabel());
		innerWords.set(i, wordAnno);
		i++;
	}
	
	annotation.setWords(innerWords);
	annotation.setPattern(patternFeature);
	annotation.setSpottingRuleName(occurrence.getRule().getName());
	annotation.setTermKey(TermSuiteUtils.getGroupingKey(annotation));
	annotation.addToIndexes();
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:35,代码来源:RegexSpotter.java

示例15: FillTermOccAnnotations

import org.apache.uima.jcas.cas.StringArray; //导入方法依赖的package包/类
private static void FillTermOccAnnotations(JsonParser parser , JsonToken token, TermOccAnnotation toa, CAS cas) throws IOException, CASException {
    if (token.equals(JsonToken.FIELD_NAME)){
        switch (parser.getCurrentName()){
            case F_PATTERN :
                String[] patternTable = parser.nextTextValue().split(" ");
                StringArray stringArray = new StringArray(cas.getJCas(), patternTable.length);

                for (int i = 0; i < patternTable.length; i++){
                    stringArray.set(i,patternTable[i]);
                }
                toa.setPattern(stringArray);
                break;

            case F_SPOTTING_RULE_NAME :
                toa.setSpottingRuleName(parser.nextTextValue());
                break;
            case F_TERM_KEY :
                toa.setTermKey(parser.nextTextValue());
                break;
            case F_WORDS :
                fillWords(toa,cas);
                break;
            case F_BEGIN :
                toa.setBegin(parser.nextIntValue(0));
                break;
            case F_END :
                toa.setEnd(parser.nextIntValue(0));
                break;
        }
    }
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:32,代码来源:JsonCasDeserializer.java


注:本文中的org.apache.uima.jcas.cas.StringArray.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。