Search in sources :

Example 1 with SebisStringBuilder

use of eu.transkribus.core.util.SebisStringBuilder in project TranskribusCore by Transkribus.

the class TrpTeiStringBuilder method setHeader.

@Override
protected void setHeader(TrpDocMetadata md) {
    SebisStringBuilder sbHeader = new SebisStringBuilder();
    sbHeader.incIndent();
    sbHeader.addLine("<teiHeader>");
    sbHeader.incIndent();
    sbHeader.addLine("<fileDesc>");
    sbHeader.incIndent();
    sbHeader.addLine("<titleStmt>");
    sbHeader.addLineWIndent("<title type='main'>" + md.getTitle() + "</title>");
    sbHeader.addLine("</titleStmt>");
    sbHeader.addLine("<publicationStmt>");
    sbHeader.addLineWIndent("<publisher>" + DEFAULT_PUBLISHER + "</publisher>");
    sbHeader.addLine("</publicationStmt>");
    sbHeader.addLine("<sourceDesc>");
    sbHeader.addLineWIndent("<bibl><publisher>" + "TRP document creator: " + md.getUploader() + "</publisher></bibl>");
    sbHeader.addLine("</sourceDesc>");
    sbHeader.decIndent();
    sbHeader.addLine("</fileDesc>");
    sbHeader.decIndent();
    writeEditorialDeclaration(sbHeader);
    sbHeader.addLine("</teiHeader>");
    sbHeader.decIndent();
    sbTotal.sb.append(sbHeader);
}
Also used : SebisStringBuilder(eu.transkribus.core.util.SebisStringBuilder)

Example 2 with SebisStringBuilder

use of eu.transkribus.core.util.SebisStringBuilder in project TranskribusCore by Transkribus.

the class TrpTeiStringBuilder method startDocument.

@Override
protected void startDocument() throws Exception {
    sbTotal = new SebisStringBuilder();
    sbTotal.addLine("<?xml version='1.0' encoding='UTF-8'?>");
    sbTotal.addLine("<TEI xmlns='http://www.tei-c.org/ns/1.0'>");
}
Also used : SebisStringBuilder(eu.transkribus.core.util.SebisStringBuilder)

Example 3 with SebisStringBuilder

use of eu.transkribus.core.util.SebisStringBuilder in project TranskribusCore by Transkribus.

the class TrpTeiStringBuilder method setContent.

@Override
protected void setContent(List<TrpPage> pages) throws JAXBException, InterruptedException {
    SebisStringBuilder sbFacsimile = new SebisStringBuilder();
    SebisStringBuilder sbText = new SebisStringBuilder();
    sbText.incIndent();
    sbText.addLine("<text>");
    sbText.incIndent();
    sbText.addLine("<body>");
    // sbText.incIndent();
    // text = tei.createElementNS(TEI_NS, "text");
    // body = tei.createElementNS(TEI_NS, "body");
    int totalPages = pageIndices == null ? pages.size() : pageIndices.size();
    if (monitor != null) {
        monitor.beginTask("Creating TEI", totalPages);
    }
    int c = 0;
    for (int i = 0; i < pages.size(); ++i) {
        if (pageIndices != null && !pageIndices.contains(i))
            continue;
        if (monitor != null) {
            if (monitor.isCanceled()) {
                throw new InterruptedException("Export was canceled by user");
            // break;
            }
            monitor.subTask("Processing page " + (c + 1));
        }
        TrpPage p = pages.get(i);
        logger.debug("1Processing page " + p.getPageNr() + ": " + p.getUrl() + " - XML=" + p.getCurrentTranscript().getUrl());
        // check buffer for transcript or unmarshal the page XML
        PcGtsType pc = this.getPcGtsTypeForPage(p);
        if (pars.hasZones()) {
            // create a facsimile element for each page that are appended to the root element of the TEI after header
            openFacsimileElement(sbFacsimile, p, pc);
        }
        // create page-break element for each page as child of body element:
        writePageBreak(sbText, p, pc);
        // 
        // // append all text-regions / lines / words to the xml:
        List<TrpRegionType> regions = pc.getPage().getTextRegionOrImageRegionOrLineDrawingRegion();
        Collections.sort(regions, new TrpElementReadingOrderComparator<RegionType>(true));
        for (TrpRegionType r : regions) {
            // System.out.println(r.getClass());
            if (r instanceof TextRegionType) {
                if (pars.hasZones()) {
                    writeZonesForTextRegion(sbFacsimile, (TrpTextRegionType) r, p.getPageNr());
                }
                writeTextForTextRegion(sbText, (TrpTextRegionType) r, p.getPageNr());
            } else {
                // write other regions
                if (pars.hasZones()) {
                    String facsId = FACS_ID_PREFIX + p.getPageNr();
                    writeZoneForShape(sbFacsimile, r, facsId, true);
                }
            }
        }
        if (pars.hasZones()) {
            closeFacsimilieElement(sbFacsimile);
        }
        ++c;
        if (monitor != null) {
            monitor.worked(c);
        }
    }
    // text.appendChild(body);
    // root.appendChild(text);
    // sbText.decIndent();
    sbText.addLine("</body>");
    sbText.decIndent();
    sbText.addLine("</text>");
    sbText.decIndent();
    sbTotal.sb.append(sbFacsimile.toString());
    sbTotal.sb.append(sbText.toString());
}
Also used : TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) RegionType(eu.transkribus.core.model.beans.pagecontent.RegionType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) TrpPage(eu.transkribus.core.model.beans.TrpPage) TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) SebisStringBuilder(eu.transkribus.core.util.SebisStringBuilder) PcGtsType(eu.transkribus.core.model.beans.pagecontent.PcGtsType) Point(java.awt.Point)

Aggregations

SebisStringBuilder (eu.transkribus.core.util.SebisStringBuilder)3 TrpPage (eu.transkribus.core.model.beans.TrpPage)1 PcGtsType (eu.transkribus.core.model.beans.pagecontent.PcGtsType)1 RegionType (eu.transkribus.core.model.beans.pagecontent.RegionType)1 TextRegionType (eu.transkribus.core.model.beans.pagecontent.TextRegionType)1 TrpRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType)1 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)1 Point (java.awt.Point)1