Search in sources :

Example 6 with DocumentMetaData

use of de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData in project dkpro-tc by dkpro.

the class TestReaderSentenceToDocument method getNext.

@Override
public void getNext(JCas aJCas) throws IOException, CollectionException {
    // setting the document text
    aJCas.setDocumentText(texts.get(offset));
    aJCas.setDocumentLanguage(LANGUAGE_CODE);
    // as we are creating more than one CAS out of a single file, we need to have different
    // document titles and URIs for each CAS
    // otherwise, serialized CASes will be overwritten
    DocumentMetaData dmd = DocumentMetaData.create(aJCas);
    dmd.setDocumentTitle("Sentence" + offset);
    dmd.setDocumentUri("Sentence" + offset);
    dmd.setDocumentId(String.valueOf(offset));
    JCasId id = new JCasId(aJCas);
    id.setId(jcasId);
    id.addToIndexes();
    // setting the outcome / label for this document
    TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas);
    outcome.setOutcome(getTextClassificationOutcome(aJCas));
    outcome.addToIndexes();
    new TextClassificationTarget(aJCas, 0, aJCas.getDocumentText().length()).addToIndexes();
    offset++;
}
Also used : JCasId(org.dkpro.tc.api.type.JCasId) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)

Example 7 with DocumentMetaData

use of de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData in project dkpro-tc by dkpro.

the class LinewiseTextOutcomeReader method initializeJCas.

protected void initializeJCas(JCas aJCas) {
    DocumentMetaData data = new DocumentMetaData(aJCas);
    data.setDocumentId(runningId + "");
    data.setDocumentTitle("Title_" + runningId);
    data.addToIndexes();
    runningId++;
}
Also used : DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)

Example 8 with DocumentMetaData

use of de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData in project dkpro-tc by dkpro.

the class TcuLookUpTable method isTheSameDocument.

private boolean isTheSameDocument(JCas aView) {
    DocumentMetaData meta = JCasUtil.selectSingle(aView, DocumentMetaData.class);
    String currentId = meta.getDocumentId();
    boolean isSame = currentId.equals(lastSeenDocumentId);
    lastSeenDocumentId = currentId;
    return isSame;
}
Also used : DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)

Example 9 with DocumentMetaData

use of de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData in project dkpro-tc by dkpro.

the class ExtractFeaturesConnector method recordDocumentMetaLog.

private void recordDocumentMetaLog(JCas aJCas) throws AnalysisEngineProcessException {
    DocumentMetaData dmd = null;
    try {
        dmd = JCasUtil.selectSingle(aJCas, DocumentMetaData.class);
        documentMetaLogger.write(dmd.getDocumentId() + "\t" + dmd.getDocumentTitle());
    } catch (IllegalArgumentException e) {
    // annotation missing
    } catch (IOException e) {
        throw new AnalysisEngineProcessException(e);
    }
}
Also used : DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData) IOException(java.io.IOException) AnalysisEngineProcessException(org.apache.uima.analysis_engine.AnalysisEngineProcessException)

Example 10 with DocumentMetaData

use of de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData in project dkpro-tc by dkpro.

the class PairReader_ImplBase method createView.

protected void createView(String part, JCas jCas, String language, String text, String docId, String docTitle) throws CASException {
    JCas view = jCas.createView(part.toString());
    view.setDocumentText(text);
    view.setDocumentLanguage(language);
    TextClassificationTarget aTarget = new TextClassificationTarget(view, 0, text.length());
    aTarget.addToIndexes();
    DocumentMetaData baseMetaData = DocumentMetaData.get(jCas);
    createMetaData(view, baseMetaData.getCollectionId(), docId, docTitle);
}
Also used : TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) JCas(org.apache.uima.jcas.JCas) DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)

Aggregations

DocumentMetaData (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)27 JCas (org.apache.uima.jcas.JCas)7 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)4 TextClassificationOutcome (org.dkpro.tc.api.type.TextClassificationOutcome)4 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)3 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 AnalysisEngineProcessException (org.apache.uima.analysis_engine.AnalysisEngineProcessException)3 CAS (org.apache.uima.cas.CAS)3 JCasId (org.dkpro.tc.api.type.JCasId)3 TextClassificationTarget (org.dkpro.tc.api.type.TextClassificationTarget)3 AnnotationDocument (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument)2 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)2 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 LinkedHashMap (java.util.LinkedHashMap)2