All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.niklasfi.rx.ThrottlerBase Maven / Gradle / Ivy

Go to download

Swiftly add ocr layers to scanned pdf files. Unfortunately existing open source ocr solutions (tesseract) pale in comparison with the ones commercially available. The azure read api provides particularly good results. It is also easy to set up, but while it can annotate text in images, there is no easy way to upload and ocr a full pdf document. That is, until now. aocr provides an easy way to ocr full pdf documents.

There is a newer version: 2.4
Show newest version
package de.niklasfi.rx;

import java.time.Duration;
import java.time.OffsetDateTime;
import java.time.temporal.TemporalAmount;

public class ThrottlerBase {
    private final TemporalAmount minInterval;
    private OffsetDateTime nextSlot;

    public ThrottlerBase(TemporalAmount minInterval) {
        this.minInterval = minInterval;
    }

    protected final long getNextSlotDelay(){
        final var now = OffsetDateTime.now();
        final long delayMs;

        if (nextSlot == null || nextSlot.isBefore(now)) {
            nextSlot = now.plus(minInterval);
            delayMs = 0;
        } else {
            delayMs = Duration.between(now, nextSlot).toMillis();
            nextSlot = nextSlot.plus(minInterval);
        }

        //System.out.printf("now: %s, delay: %s, next: %s%n", now, delayMs, nextSlot);
        return delayMs;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy