<commit_before>package eu.amidst.core.huginlink;

import COM.hugin.HAPI.*;

import COM.hugin.HAPI.Node;
import eu.amidst.core.distribution.*;
import eu.amidst.core.variables.DistType;
import eu.amidst.core.variables.StaticVariables;
import eu.amidst.core.variables.Variable;
import eu.amidst.core.models.BayesianNetwork;
import eu.amidst.core.models.DAG;
import eu.amidst.core.utils.MultinomialIndex;

import java.util.List;

public class ConverterToHugin {

    private Domain huginBN;
    private BayesianNetwork amidstBN;

    public ConverterToHugin(BayesianNetwork amidstBN_) throws ExceptionHugin {

        this.huginBN = new Domain();
        this.amidstBN = amidstBN_;
    }

    public Domain getHuginNetwork(){
        return this.huginBN;
    }

    public void setNodes() throws ExceptionHugin {

        StaticVariables amidstVars = amidstBN.getStaticVariables();
        int size = amidstVars.getNumberOfVars();

        //Hugin always inserts variables in position 0, i.e, for an order A,B,C, it stores C,B,A !!!
        //A reverse order of the variables is used instead.
        for(int i=1;i<=size;i++){
            Variable amidstVar = amidstVars.getVariableById(size-i);
            if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) == 0) {
                LabelledDCNode n = new LabelledDCNode(this.huginBN);
                n.setName(amidstVar.getName());
                n.setNumberOfStates(amidstVar.getNumberOfStates());

                for (int j=0;j<n.getNumberOfStates();j++){
                    n.setStateLabel(j,amidstVar.getName()+j);
                }
            } else if (amidstVar.getDistributionType().compareTo(DistType.GAUSSIAN) == 0) {
                ContinuousChanceNode c = new ContinuousChanceNode(this.huginBN);
                c.setName(amidstVar.getName());
            } else {
                throw new IllegalArgumentException("Unrecognized DistributionType.");
            }
        }
    }


    public void setStructure () throws ExceptionHugin {

        DAG dag = amidstBN.getDAG();<commit_msg>My files up to date<commit_after>package eu.amidst.core.huginlink;

import COM.hugin.HAPI.*;

import COM.hugin.HAPI.Node;
import eu.amidst.core.distribution.*;
import eu.amidst.core.variables.DistType;
import eu.amidst.core.variables.MultinomialStateSpace;
import eu.amidst.core.variables.StaticVariables;
import eu.amidst.core.variables.Variable;
import eu.amidst.core.models.BayesianNetwork;
import eu.amidst.core.models.DAG;
import eu.amidst.core.utils.MultinomialIndex;

import java.util.List;

public class ConverterToHugin {

    private Domain huginBN;
    private BayesianNetwork amidstBN;

    public ConverterToHugin(BayesianNetwork amidstBN_) throws ExceptionHugin {

        this.huginBN = new Domain();
        this.amidstBN = amidstBN_;
    }

    public Domain getHuginNetwork(){
        return this.huginBN;
    }

    public void setNodes() throws ExceptionHugin {

        StaticVariables amidstVars = amidstBN.getStaticVariables();
        int size = amidstVars.getNumberOfVars();

        //Hugin always inserts variables in position 0, i.e, for an order A,B,C, it stores C,B,A !!!
        //A reverse order of the variables is used instead.
        for(int i=1;i<=size;i++){
            Variable amidstVar = amidstVars.getVariableById(size-i);
            if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) == 0) {
                LabelledDCNode n = new LabelledDCNode(this.huginBN);
                n.setName(amidstVar.getName());
                n.setNumberOfStates(amidstVar.getNumberOfStates());
                for (int j=0;j<n.getNumberOfStates();j++){
                    String stateName = ((MultinomialStateSpace)amidstVar.getStateSpace()).getStatesName(j);
                    n.setStateLabel(j, stateName);
                }
            } else if (amidstVar.getDistributionType().compareTo(DistType.GAUSSIAN) == 0) {
                ContinuousChanceNode c = new ContinuousChanceNode(this.huginBN);
                c.setName(amidstVar.getName());
            } else {
                throw new IllegalArgumentException("Unrecognized DistributionType.");
            }
        }
    }


    public void setStructure () throws ExceptionHugin {

        DAG dag = amidstBN.getDAG();
{'fraction_non_alphanumeric': 0.10449150570165232, 'fraction_numerical': 0.0023272050267628577, 'mean_word_length': 2.737391304347826, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1370608', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1238, 'n_words': 251}