com.khala.extractor.QaExtractor2 Maven / Gradle / Ivy
package com.khala.extractor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.function.Consumer;
import com.eshore.framework.ComponentFactory;
import com.eshore.framework.DataService;
import com.eshore.framework.impl.ComponentFactoryJSON;
import com.eshore.framework.pipeline.Pipeline;
import com.eshore.kg.qa.extract.QaManager;
import com.eshore.kg.qa.extract.Question;
import com.eshore.minio.MinioDataService;
import com.eshore.utils.Timer;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
public class QaExtractor2 implements AutoCloseable {
private ComponentFactory componentFactory;
public QaExtractor2() throws InvalidEndpointException, InvalidPortException, IOException {
this(new MinioDataService("http://chart7apppmo9piw6-minio.qa:9000", "idsuS4z5yyi42Velk0UJ",
"s73rQj2hdyqbhxoWLKHcMCkeKQqHhUtrr3ORdOyR", "extract"));
}
public QaExtractor2(DataService dataService) throws IOException {
Timer timer = new Timer();
componentFactory = new ComponentFactoryJSON(dataService);
timer.time("components ready in ");
}
public void extract(File f, Consumer> callback) throws IOException {
try (InputStream in = new FileInputStream(f)) {
extract(in, callback);
}
}
public void extract(InputStream in, Consumer> callback) throws IOException {
componentFactory.get(QaManager.class).extract(in, callback);
}
public ComponentFactory getComponentFactory() {
return componentFactory;
}
@Override
public void close() throws Exception {
componentFactory.get(Pipeline.class).close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy