package eu.modernmt.decoder.moses;

import eu.modernmt.context.ContextDocument;

import java.util.List;

/**
 * Created by davide on 27/04/16.
 */
class ContextXObject {

    public final String[] keys;
    public final float[] values;

    public static ContextXObject build(List<ContextDocument> context) {
        if (context != null && context.size() > 0) {
            String[] keys = new String[context.size()];
            float[] values = new float[context.size()];

            int i = 0;
            for (ContextDocument document : context) {
                keys[i] = document.getId();
                values[i] = document.getScore();
                i++;
            }

            return new ContextXObject(keys, values);
        } else {
            return null;
        }
    }

    private ContextXObject(String[] keys, float[] values) {
        this.keys = keys;
        this.values = values;
    }
}

@@ -333,30 +333,8 @@
 null
- && context.size() %3E 0
 ) %7B%0A

Fix #142: empty session can now be used without throwing NullPointerException