Refine search
/** initialize variables to correspond with Cas Type and Features * @generated * @param jcas JCas * @param casType Type */ public Stem_Type(JCas jcas, Type casType) { super(jcas, casType); casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator()); casFeat_value = jcas.getRequiredFeatureDE(casType, "value", "uima.cas.String", featOkTst); casFeatCode_value = (null == casFeat_value) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_value).getCode(); } }
public TOP(JCas jcas) { CASImpl casImpl = (CASImpl)jcas.getCas(); this.jcasType = jcas.getType(getTypeIndexID()); if (null == jcasType) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS, new String[] { this.getClass().getName() }); throw e; } boolean isSubtypeOfAnnotationBase = casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode); if (isSubtypeOfAnnotationBase && (casImpl.getBaseCAS() == casImpl)) { throw new CASRuntimeException(CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS, new String[] { this.getClass().getName() }); } this.addr = jcasType.ll_cas.ll_createFS(jcasType.casTypeCode); jcas.putJfsFromCaddr(addr, this); if (casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode)) { casImpl.setSofaFeat(addr, casImpl.getSofaRef()); } }
public void addSofa(FeatureStructure sofa, String sofaName, String mimeType) { if (this.svd.sofaNameSet.contains(sofaName)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFANAME_ALREADY_EXISTS, new String[] { sofaName }); throw e; } final int llsofa = ll_getFSRef(sofa); if (0 == ll_getIntValue(llsofa, TypeSystemImpl.sofaNumFeatCode)) { ll_setIntValue(llsofa, TypeSystemImpl.sofaNumFeatCode, ++this.svd.viewCount); } ll_setStringValue(llsofa, TypeSystemImpl.sofaIdFeatCode, sofaName); ll_setStringValue(llsofa, TypeSystemImpl.sofaMimeFeatCode, mimeType); this.getBaseIndexRepository().addFS(sofa); this.svd.sofaNameSet.add(sofaName); }
/** * Deserialize the data in a CASSerializer into an existing CAS, * return the currentview in that Cas. * @param casMgr the CAS Manager * @param casSer the serializer * @return the initialized CAS loaded with the deserialized data */ public static CAS createCAS(CASMgr casMgr, CASSerializer casSer) { ((CASImpl) casMgr).reinit(casSer); return ((CASImpl) casMgr).getCurrentView(); }
@Override public String getDocumentLanguage() { if (this == this.svd.baseCAS) { // base CAS has no document return null; } final int docAnnotAddr = ll_getFSRef(getDocumentAnnotation()); return ll_getStringValue(docAnnotAddr, TypeSystemImpl.langFeatCode); }
@Override public AnnotationFS createAnnotation(Type type, int begin, int end) { if (this == this.svd.baseCAS) { // Can't create annotation on base CAS CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INVALID_BASE_CAS_METHOD, new String[] { "createAnnotation(Type, int, int)" }); throw e; } FeatureStructure fs = createFS(type); final int addr = ll_getFSRef(fs); // setSofaFeat(addr, this.mySofaRef); // already done by createFS setFeatureValueNotJournaled(addr, TypeSystemImpl.startFeatCode, begin); // because it's a create - not in index // setStartFeat(addr, begin); setFeatureValueNotJournaled(addr, TypeSystemImpl.endFeatCode, end); // because it's a create - not in index // setEndFeat(addr, end); return (AnnotationFS) fs; }
protected void applyChanges(JCas aSourceView, JCas aTargetView) { AlignedString as = AlignmentFactory.createAlignmentsFor(aSourceView); // Set the text of the new Sofa aTargetView.setDocumentText(as.get()); // Set document language aTargetView.setDocumentLanguage(aSourceView.getDocumentLanguage()); // Optionally we may want to remember the AlignedString for the backmapper. AlignmentStorage.getInstance().put(aSourceView.getCasImpl().getBaseCAS(), aSourceView.getViewName(), aTargetView.getViewName(), as); } }
CompressLevel compressLevel, CompressStrat compressStrategy) throws ResourceInitializationException { cas = ((CASImpl) ((aCas instanceof JCas) ? ((JCas)aCas).getCas(): aCas)).getBaseCAS(); this.ts = cas.getTypeSystemImpl(); this.mark = mark; if (null != mark && !mark.isValid() ) { isTsiIncluded = storeTSI; heap = cas.getHeap().heap; heapEnd = cas.getHeap().getCellsUsed(); heapStart = isSerializingDelta ? mark.getNextFSId() : 0; stringHeapObj = cas.getStringHeap(); longHeapObj = cas.getLongHeap(); shortHeapObj = cas.getShortHeap(); byteHeapObj = cas.getByteHeap();
private static void forceSetFeatureValue(FeatureStructure aFS, String aFeatureName, String aValue) { CASImpl casImpl = (CASImpl) aFS.getCAS().getLowLevelCAS(); TypeSystemImpl ts = (TypeSystemImpl) aFS.getCAS().getTypeSystem(); Feature feat = aFS.getType().getFeatureByBaseName(aFeatureName); int featCode = ((FeatureImpl) feat).getCode(); int thisType = ((TypeImpl) aFS.getType()).getCode(); if (!ts.isApprop(thisType, featCode)) { throw new IllegalArgumentException("Feature structure does not have that feature"); } if (!ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), feat.getRange())) { throw new IllegalArgumentException("Not a string feature!"); } casImpl.ll_setStringValue(casImpl.ll_getFSRef(aFS), featCode, aValue); }
private AlignedString getAlignedString(JCas aSomeCase, String from, String to) throws AnalysisEngineProcessException, CASException { CAS baseCas = aSomeCase.getCasImpl().getBaseCAS(); // Try to get the AlignedString for the current JCas. AlignmentStorage asstore = AlignmentStorage.getInstance(); AlignedString as = asstore.get(baseCas, to, from); if (as == null) { // Attempt to reconstruct the alignment from the SofaChangeAnnotations. // This only works when they have not been altered in the mean time. ExtendedLogger logger = getLogger(); if (logger.isInfoEnabled()) { logger.info("No mapping found from [" + from + "] to [" + to + "] on [" + baseCas.hashCode() + "]. " + "Restoring mapping from SofaChangeAnnotation found in [" + to + "]." ); } JCas view = aSomeCase.getCas().getView(to).getJCas(); as = AlignmentFactory.createAlignmentsFor(view); } // If there is none we have to fail. Practically this should never happen // when the alignment state is reconstructed in the previous step. if (as == null) { throw new AnalysisEngineProcessException(new IllegalStateException( "No mapping found from [" + from + "] to [" + to + "] on [" + baseCas.hashCode() + "]")); } return as; }
public void setFeatureValue(Feature feat, FeatureStructure fs) { final int valueAddr = this.getCASImpl().ll_getFSRef(fs); final int featCode = ((FeatureImpl) feat).getCode(); final int rangeType = this.getCASImpl().getTypeSystemImpl().range(featCode); if (valueAddr == CASImpl.NULL) { setNullValue(featCode, rangeType); return; } final int thisType = this.getCASImpl().getHeapValue(this.getAddress()); final int valueType = this.getCASImpl().getHeapValue(valueAddr); if (!this.getCASImpl().getTypeSystemImpl().isApprop(thisType, featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE, new String[] { feat.getName(), this.getType().getName() }); throw e; } if (!this.getCASImpl().getTypeSystemImpl().subsumes(rangeType, valueType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_RANGE, new String[] { feat.getName(), feat.getRange().getName(), fs.getType().getName() }); throw e; } // keys are not fsRefs this.getCASImpl().setFeatureValueNoIndexCorruptionCheck(this.getAddress(), featCode, valueAddr); }
XmiSerializationSharedData sharedData, int mergePoint, AllowPreexistingFS allowPreexistingFS) { super(); this.casBeingFilled = aCAS.getBaseCAS(); this.lenient = lenient; this.sharedData = casBeingFilled.resetNoQuestions(); this.nextSofaNum = this.casBeingFilled.getBaseSofaCount() + 1; this.indexRepositories = new ArrayList<FSIndexRepository>(); this.views = new ArrayList<CAS>(); indexRepositories.add(this.casBeingFilled.getBaseIndexRepository()); indexRepositories.add(this.casBeingFilled.getView(CAS.NAME_DEFAULT_SOFA).getIndexRepository()); FSIterator<SofaFS> sofaIter = this.casBeingFilled.getSofaIterator(); while(sofaIter.hasNext()) { SofaFS sofa = sofaIter.next(); if (sofa.getSofaRef() == 1) { casBeingFilled.registerInitialSofa(); } else { indexRepositories.add(casBeingFilled.getSofaIndexRepository(sofa)); final TypeSystemImpl tsOfReceivingCas = casBeingFilled.getTypeSystemImpl(); this.sofaTypeCode = tsOfReceivingCas.ll_getCodeForTypeName(CAS.TYPE_NAME_SOFA); this.sofaNumFeatCode = tsOfReceivingCas.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_SOFANUM);
assert ((CASImpl) aFS.getCAS()).getBaseCAS() == ((CASImpl) mSrcCas).getBaseCAS(); int typeCode = mLowLevelDestCas.ll_getTypeSystem().ll_getCodeForType(destType); int destFsAddr = mLowLevelDestCas.ll_createFS(typeCode); FeatureStructure destFs = mDestCas.getLowLevelCAS().ll_getFSForRef(destFsAddr);
casImpl.reset(); serializer.longHeapArray = aLongHeapArray; casImpl.reinit(serializer); ResultSpecification rs = ae.createResultSpecification(casImpl.getTypeSystem()); for (int i = 0; i < resultSpecTypes.length; ++i) { .addResultType(casImpl.getTypeSystemImpl().ll_getTypeForCode(resultSpecTypes[i]).getName(), false); rs.addResultFeature(casImpl.getTypeSystemImpl().ll_getFeatureForCode(resultSpecFeatures[i]) .getName()); exceptionString = "This CasConsumer expects a View, but the Sofa from which to construct one is not specified."; } else if (sofaNum > 0) { CAS view = casImpl.getView(sofaNum); cc.processCas(view); } else {
public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof TOP)) return false; TOP fs = (TOP) o; if ((this.addr == fs.addr) && (this.jcasType.casImpl.getBaseCAS() == fs.jcasType.casImpl.getBaseCAS())) { return true; } return false; }
tgtCasViewImpl = (CASImpl) aTgtCasView.getLowLevelCAS(); srcViewName = srcCasViewImpl.getViewName(); tgtViewName = tgtCasViewImpl.getViewName(); isChangeViewName = !srcViewName.equals(tgtViewName); if ((aSrcCasView == srcCasViewImpl.getBaseCAS()) || (aTgtCasView == tgtCasViewImpl.getBaseCAS())) { throw new UIMARuntimeException(UIMARuntimeException.UNSUPPORTED_CAS_COPY_TO_OR_FROM_BASE_CAS, null); SofaFS sofa = srcCasViewImpl.getSofa(); if (null != sofa) { if (srcCasViewImpl.getDocumentText() != null) { aTgtCasView.setSofaDataString(srcCasViewImpl.getDocumentText(), sofaMime); } else if (srcCasViewImpl.getSofaDataURI() != null) { aTgtCasView.setSofaDataURI(srcCasViewImpl.getSofaDataURI(), sofaMime); } else if (srcCasViewImpl.getSofaDataArray() != null) { aTgtCasView.setSofaDataArray(copyFs2Fs(srcCasViewImpl.getSofaDataArray()), sofaMime); LowLevelIterator it = ((FSIndexRepositoryImpl)(srcCasViewImpl.getIndexRepository())).ll_getAllIndexedFS(srcTsi.getTopType()); if (originalSrcCasImpl.isSubtypeOfAnnotationBaseType(originalSrcCasImpl.getTypeCode(fs))) { int sofaRef = tgtCasViewImpl.ll_getRefValue(copyOfFs, mDestSofaFeatureCode); if (0 == sofaRef) { tgtCasViewImpl.ll_setRefValue(copyOfFs, mDestSofaFeatureCode, tgtCasViewImpl.getSofaRef()); tgtCasViewImpl.ll_getIndexRepository().ll_addFS(copyOfFs);
TypeSystemImpl ts) throws CASRuntimeException { if (this != this.svd.baseCAS) { return this.svd.baseCAS.reinit(h, istream, casMgrSerializer, casLoadMode, f6, allowPreexistingFS, ts); CASMgrSerializer embeddedCasMgrSerializer = maybeReadEmbeddedTSI(h, dis); setupCasFromCasMgrSerializer( (null != embeddedCasMgrSerializer && embeddedCasMgrSerializer.hasIndexRepository()) ? embeddedCasMgrSerializer this.resetNoQuestions(); (new BinaryCasSerDes4(this.getTypeSystemImpl(), false)).deserialize(this, dis, delta); return h.typeSystemIndexDefIncluded ? SerialFormat.COMPRESSED_TSI : SerialFormat.COMPRESSED; this.getHeap().reinitSizeOnly(fsheapsz); } else { startPos = this.getHeap().getNextId(); this.getHeap().grow(fsheapsz); this.getHeap().heap[i] = r.readInt(); this.getStringHeap().reinit(shdh, delta); final int heapsize = this.getHeap().getNextId(); for (fsAddr = 1; fsAddr < heapsize; fsAddr = getNextFsHeapAddr(fsAddr)) { fss.add(fsAddr);
/** * @see UimaContextAdmin#returnedCAS(AbstractCas) */ public void returnedCAS(AbstractCas aCAS) { //remove Base CAS from outstanding CASes set CAS baseCas = null; if (aCAS instanceof JCas) { baseCas = ((JCas)aCAS).getCasImpl().getBaseCAS(); } else if (aCAS instanceof CASImpl) { baseCas = ((CASImpl)aCAS).getBaseCAS(); } mOutstandingCASes.remove(baseCas); // mOutstandingCASes is thread-safe (Concurrent hash map) }
public void releaseCas(AbstractCas aCAS) { if (!(aCAS instanceof CASImpl) && !(aCAS instanceof JCas)) { throw new UIMARuntimeException(UIMARuntimeException.UNSUPPORTED_CAS_INTERFACE, new Object[] {aCAS.getClass()}); } CASImpl baseCas = (aCAS instanceof JCas) ? ((JCas)aCAS).getCasImpl().getBaseCAS() : ((CASImpl)aCAS).getBaseCAS(); if (baseCas.containsCasState(CasState.UIMA_AS_WAIT_4_RESPONSE)) { throw new UIMARuntimeException(UIMARuntimeException.CAS_RELEASE_NOT_ALLOWED_WHILE_WAITING_FOR_UIMA_AS, new Object[0]); } CasPool pool = mCasToCasPoolMap.get(baseCas); if (pool == null) { // CAS doesn't belong to this CasManager! throw new UIMARuntimeException(UIMARuntimeException.CAS_RELEASED_TO_WRONG_CAS_MANAGER, new Object[0]); } else { //see if we have a UimaContext that we can notify that CAS was release UimaContextAdmin uc = (UimaContextAdmin)mCasToUimaContextMap.get(baseCas); if (uc != null) { uc.returnedCAS(aCAS); } //release the CAS pool.releaseCas((CAS) aCAS); } }
private void storeReferencesAndTargetsInMap(Map<Integer, CoreferenceLink> aReferencesMap, eu.clarin.weblicht.wlfxb.tc.api.ReferencedEntity entity, TextCorpus aCorpusData, Map<String, Token> aTokens, JCas aJcas) { for (Reference reference : entity.getReferences()) { StringBuilder sbTokens = new StringBuilder(); for (eu.clarin.weblicht.wlfxb.tc.api.Token token : aCorpusData.getReferencesLayer() .getTokens(reference)) { sbTokens.append(token.getID()).append(" "); } String[] referenceTokens = sbTokens.toString().split(" "); int begin = getOffsets(referenceTokens, aTokens)[0]; int end = getOffsets(referenceTokens, aTokens)[1]; CoreferenceLink link = new CoreferenceLink(aJcas); link.setBegin(begin); link.setEnd(end); String referencesType = reference.getType() == null ? "nam" : reference.getType(); link.setReferenceType(referencesType); if (reference.getRelation() != null) { link.setReferenceRelation(reference.getRelation()); } link.addToIndexes(); aReferencesMap.put(aJcas.getCasImpl().ll_getFSRef(link), link); } }