Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Myyyvothrr committed Jul 10, 2024
1 parent 972ba23 commit b2cc70e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@
import org.apache.commons.compress.compressors.CompressorInputStream;
import org.apache.commons.compress.compressors.CompressorOutputStream;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
import org.apache.uima.util.TypeSystemUtil;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
* Helper class for compression and decompression of strings.
*/
public class DUUICompressionHelper {
CompressorStreamFactory _factory;
String _method;

/**
* Constructor using a {@link CompressorStreamFactory} and a compression method.
* @param method
*/
public DUUICompressionHelper(String method) {
_factory = new CompressorStreamFactory();
_method = method;
}

/**
* Compresses a string.
* @param input The string to compress.
* @return The compressed string as a base64 encoded string.
* @throws IOException
* @throws CompressorException
*/
public String compress(String input) throws IOException, CompressorException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
CompressorOutputStream output = _factory.createCompressorOutputStream(_method,out);
Expand All @@ -30,6 +42,13 @@ public String compress(String input) throws IOException, CompressorException {
return new String(Base64.getEncoder().encode(out.toByteArray()), StandardCharsets.UTF_8);
}

/**
* Decompresses a string.
* @param input The compressed string as a base64 encoded string.
* @return The decompressed string.
* @throws IOException
* @throws CompressorException
*/
public String decompress(String input) throws IOException, CompressorException {
ByteArrayInputStream inputstream = new ByteArrayInputStream(Base64.getDecoder().decode(input.getBytes(StandardCharsets.UTF_8)));
CompressorInputStream inpst = _factory.createCompressorInputStream(_method, inputstream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
import java.net.URISyntaxException;
import java.util.Vector;

/**
* Description of a pipeline for the DUUI composer that holds all components.
*/
public class DUUIPipelineDescription {
private Vector<DUUIPipelineAnnotationComponent> _components;

/**
* Constructor
* @param components List of components of the pipeline.
*/
public DUUIPipelineDescription(Vector<DUUIPipelineAnnotationComponent> components) {
_components = components;
}

/**
* Get the components of the pipeline.
* @return List of components.
*/
public Vector<DUUIPipelineAnnotationComponent> getComponents() {
return _components;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,41 @@
import java.util.List;
import java.util.Map;

/**
* Interface for communication between the DUUI composer {@link DUUIComposer} and the components {@link org.texttechnologylab.DockerUnifiedUIMAInterface.driver.IDUUIDriverInterface}.
*/
public interface IDUUICommunicationLayer {
/**
* Serializes a JCas to a byte array output stream by using the LUA script provided by the component.
* @param jc Input JCas.
* @param out Output stream, i.e. the input to the component.
* @param parameters Parameters for use in the LUA script.
* @throws CompressorException
* @throws IOException
* @throws SAXException
*/
public void serialize(JCas jc, ByteArrayOutputStream out, Map<String,String> parameters) throws CompressorException, IOException, SAXException;

/**
* Deserializes a byte array input stream to a JCas by using the LUA script provided by the component.
* @param jc Output JCas, note that the CAS is not reset before deserialization.
* @param input Input stream, i.e. the output of the component.
* @throws IOException
* @throws SAXException
*/
public void deserialize(JCas jc, ByteArrayInputStream input) throws IOException, SAXException;

/**
*
* @return
*/
public IDUUICommunicationLayer copy();

/**
*
* @param results
* @return
*/
public ByteArrayInputStream merge(List<ByteArrayInputStream> results);

String myLuaTestMerging();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.List;
import java.util.concurrent.Future;

/**
* Interface for execution plans of the DUUI composer pipleine.
*/
public interface IDUUIExecutionPlan {
public List<IDUUIExecutionPlan> getNextExecutionPlans();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

import org.apache.uima.jcas.JCas;

/**
* Interface for generating execution plans {@link IDUUIExecutionPlan}.
*/
public interface IDUUIExecutionPlanGenerator {
/**
* Generates an execution plan for a given JCas.
* @param jc The JCas to generate the execution plan for.
* @return The generated execution plan.
*/
public IDUUIExecutionPlan generate(JCas jc);
}

0 comments on commit b2cc70e

Please sign in to comment.