Search in sources :

Example 26 with TextLineType

use of eu.transkribus.core.model.beans.pagecontent.TextLineType in project TranskribusCore by Transkribus.

the class TrpPageTypeUtils method assignUniqueIDs.

/**
 * Assigns unique IDs to the elements in the page using the current order of the elements.
 */
public static void assignUniqueIDs(PageType page) {
    int i = 1;
    for (RegionType r : page.getTextRegionOrImageRegionOrLineDrawingRegion()) {
        if (r instanceof TextRegionType) {
            TextRegionType region = (TextRegionType) r;
            String rid = "r" + i;
            region.setId(rid);
            int j = 1;
            for (TextLineType l : region.getTextLine()) {
                String lid = rid + "l" + j;
                l.setId(lid);
                int k = 1;
                for (WordType word : l.getWord()) {
                    String wid = lid + "w" + k;
                    word.setId(wid);
                    k++;
                }
                ++j;
            }
            ++i;
        }
    }
}
Also used : TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) RegionType(eu.transkribus.core.model.beans.pagecontent.RegionType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) TextLineType(eu.transkribus.core.model.beans.pagecontent.TextLineType) WordType(eu.transkribus.core.model.beans.pagecontent.WordType)

Example 27 with TextLineType

use of eu.transkribus.core.model.beans.pagecontent.TextLineType in project TranskribusCore by Transkribus.

the class CustomTagUtil method getIndexedCustomTagsForLines.

public static <T extends CustomTag> List<T> getIndexedCustomTagsForLines(TrpTextRegionType region, String tagName) {
    List<T> tags = new ArrayList<>();
    CustomTag ct = null;
    for (TextLineType l : region.getTextLine()) {
        TrpTextLineType tl = (TrpTextLineType) l;
        List<T> lineTags = tl.getCustomTagList().getIndexedTags(tagName);
        for (T t : lineTags) {
            if (ct != null && isContinuation(tagName, t)) {
                ct.continuations.add(t);
            } else {
                tags.add(t);
                ct = t.isContinued() ? t : null;
            }
        }
    }
    return tags;
}
Also used : TrpTextLineType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType) TextLineType(eu.transkribus.core.model.beans.pagecontent.TextLineType) TrpTextLineType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType) ArrayList(java.util.ArrayList)

Aggregations

TextLineType (eu.transkribus.core.model.beans.pagecontent.TextLineType)27 TrpTextLineType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType)19 WordType (eu.transkribus.core.model.beans.pagecontent.WordType)13 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)13 TextRegionType (eu.transkribus.core.model.beans.pagecontent.TextRegionType)9 TrpWordType (eu.transkribus.core.model.beans.pagecontent_trp.TrpWordType)9 RegionType (eu.transkribus.core.model.beans.pagecontent.RegionType)6 Rectangle (java.awt.Rectangle)6 ArrayList (java.util.ArrayList)5 TrpPage (eu.transkribus.core.model.beans.TrpPage)4 TrpElementCoordinatesComparator (eu.transkribus.core.model.beans.pagecontent_trp.TrpElementCoordinatesComparator)4 TrpPageType (eu.transkribus.core.model.beans.pagecontent_trp.TrpPageType)4 TrpRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType)4 TrpTranscriptMetadata (eu.transkribus.core.model.beans.TrpTranscriptMetadata)3 TrpBaselineType (eu.transkribus.core.model.beans.pagecontent_trp.TrpBaselineType)3 Point (java.awt.Point)3 JAXBPageTranscript (eu.transkribus.core.model.beans.JAXBPageTranscript)2 TrpTranscriptStatistics (eu.transkribus.core.model.beans.TrpTranscriptStatistics)2 PcGtsType (eu.transkribus.core.model.beans.pagecontent.PcGtsType)2 TextEquivType (eu.transkribus.core.model.beans.pagecontent.TextEquivType)2