<commit_before>package mstparser.old;

import mstparser.DependencyInstance;
import mstparser.FeatureVector;
import mstparser.KBestParseForest;
import mstparser.ParseForestItem;

import scala.Tuple2;

public abstract class DependencyDecoder2O extends DependencyDecoder {
  protected abstract Tuple2<Integer, Integer> getSibs(int ch, int[] par);

    protected void rearrange(double[][][] probs,
			   double[][][] probs_trips,
			   double[][][] probs_sibs, double[][][][] nt_probs, int[] par, int[] labs) {
		
	int[][] static_types = null;
	if(this.pipe().getLabeled()) {
	    static_types = getTypes(nt_probs,par.length);
	}

	boolean[][] isChild = calcChilds(par);
	boolean[][] isCross = null;
		
	while(true) {
	    int wh = -1;
	    int nPar = -1;
	    int nType = -1;
	    double max = Double.NEGATIVE_INFINITY;
	    int[][] aSibs = new int[par.length][par.length];
	    int[][] bSibs = new int[par.length][par.length];
	    for(int i = 1; i < par.length; i++) {
		for(int j = 0; j < par.length; j++) {
		    int oP = par[i];
		    par[i] = j;
		    Tuple2<Integer, Integer> sibs = getSibs(i,par);
		    aSibs[i][j] = sibs._1(); bSibs[i][j] = sibs._2();
		    par[i] = oP;
		}
	    }
	    for(int ch = 1; ch < par.length; ch++) {
		// Calculate change of removing edge
		int aSib = aSibs[ch][par[ch]]; int bSib = bSibs[ch][par[ch]];
		boolean lDir = ch < par[ch];
		double change = 0.0 - probs[lDir ? ch : par[ch]][lDir ? par[ch] : ch][lDir ? 1 : 0]
		    - probs_trips[par[ch]][aSib][ch] - probs_sibs[aSib][ch][aSib == par[ch] ? 0 : 1]
		    - (bSib != ch ? probs_trips[par[ch]][ch][bSib] + probs_sibs[ch][bSib][1] : 0.0)
		    - (this.pipe().getLabeled() ? (nt_probs[ch][labs[ch]][lDir ? 1 : 0][0] + nt_probs[par[ch]][labs[ch]][lDir ? 1 : 0][1]) : 0.0)
		    + (bSib != ch ? probs_trips[par[ch]][aSib][bSib] + probs_sibs[aSib][bSib][aSib == par[ch] ? 0 : 1] : 0.0);
		for(int pa = 0; pa < par.length; pa++) {
		    if(ch == pa || pa == par[ch] || isChild[ch][pa]) continue;
		    aSib = aSibs[ch][pa]; bSib = bSibs[ch][pa];
		    boolean lDir1 = ch < pa;
		    double change1 = 0.0 + probs[lDir1 ? ch : pa][lDir1 ? pa : ch][lDir1 ? 1 : 0]
			+ probs_trips[pa][aSib][ch] + probs_sibs[aSib][ch][aSib == pa ? 0 : 1]
			+ (bSib != ch ? probs_trips[pa][ch][bSib] + probs_sibs[ch][bSib][1] : 0.0)
			+ (this.pipe().getLabeled() ? (nt_probs[ch][static_types[pa][ch]][lDir1 ? 1 : 0][0] + nt_probs[pa][static_types[pa][ch]][lDir1 ? 1 : 0][1]) : 0.0)
			- (bSib != ch ? probs_trips[pa][aSib][bSib] + probs_sibs[aSib][bSib][aSib == pa ? 0 : 1] : 0.0);
		    if(max < change+change1) {
			max = change+change1; wh = ch; nPar = pa; nType = this.pipe().getLabeled() ? static_types[pa][ch] : 0;
		    }
		}
	    }
	    if(max <= 0.0)
		break;
	    par[wh] = nPar;
	    labs[wh] = nType;
	    isChild = calcChilds(par);
	    //System.out.println(max + " " + wh + " " + nPar + " " + nType);
	}
    }
}
<commit_msg>Removing unnecessary imports, etc.<commit_after>package mstparser.old;

import scala.Tuple2;

public abstract class DependencyDecoder2O extends DependencyDecoder {
  protected abstract Tuple2<Integer, Integer> getSibs(int ch, int[] par);

    protected void rearrange(double[][][] probs,
			   double[][][] probs_trips,
			   double[][][] probs_sibs, double[][][][] nt_probs, int[] par, int[] labs) {
		
	int[][] static_types = null;
	if (this.pipe().getLabeled()) static_types = getTypes(nt_probs,par.length);

	boolean[][] isChild = calcChilds(par);
	boolean[][] isCross = null;
		
	while (true) {
	    int wh = -1;
	    int nPar = -1;
	    int nType = -1;
	    double max = Double.NEGATIVE_INFINITY;
	    int[][] aSibs = new int[par.length][par.length];
	    int[][] bSibs = new int[par.length][par.length];
	    for(int i = 1; i < par.length; i++) {
		for(int j = 0; j < par.length; j++) {
		    int oP = par[i];
		    par[i] = j;
		    Tuple2<Integer, Integer> sibs = getSibs(i,par);
		    aSibs[i][j] = sibs._1(); bSibs[i][j] = sibs._2();
		    par[i] = oP;
		}
	    }
	    for(int ch = 1; ch < par.length; ch++) {
		// Calculate change of removing edge
		int aSib = aSibs[ch][par[ch]]; int bSib = bSibs[ch][par[ch]];
		boolean lDir = ch < par[ch];
		double change = 0.0 - probs[lDir ? ch : par[ch]][lDir ? par[ch] : ch][lDir ? 1 : 0]
		    - probs_trips[par[ch]][aSib][ch] - probs_sibs[aSib][ch][aSib == par[ch] ? 0 : 1]
		    - (bSib != ch ? probs_trips[par[ch]][ch][bSib] + probs_sibs[ch][bSib][1] : 0.0)
		    - (this.pipe().getLabeled() ? (nt_probs[ch][labs[ch]][lDir ? 1 : 0][0] + nt_probs[par[ch]][labs[ch]][lDir ? 1 : 0][1]) : 0.0)
		    + (bSib != ch ? probs_trips[par[ch]][aSib][bSib] + probs_sibs[aSib][bSib][aSib == par[ch] ? 0 : 1] : 0.0);
		for(int pa = 0; pa < par.length; pa++) {
		    if(ch == pa || pa == par[ch] || isChild[ch][pa]) continue;
		    aSib = aSibs[ch][pa]; bSib = bSibs[ch][pa];
		    boolean lDir1 = ch < pa;
		    double change1 = 0.0 + probs[lDir1 ? ch : pa][lDir1 ? pa : ch][lDir1 ? 1 : 0]
			+ probs_trips[pa][aSib][ch] + probs_sibs[aSib][ch][aSib == pa ? 0 : 1]
			+ (bSib != ch ? probs_trips[pa][ch][bSib] + probs_sibs[ch][bSib][1] : 0.0)
			+ (this.pipe().getLabeled() ? (nt_probs[ch][static_types[pa][ch]][lDir1 ? 1 : 0][0] + nt_probs[pa][static_types[pa][ch]][lDir1 ? 1 : 0][1]) : 0.0)
			- (bSib != ch ? probs_trips[pa][aSib][bSib] + probs_sibs[aSib][bSib][aSib == pa ? 0 : 1] : 0.0);
		    if(max < change+change1) {
			max = change+change1; wh = ch; nPar = pa; nType = this.pipe().getLabeled() ? static_types[pa][ch] : 0;
		    }
		}
	    }
	    if(max <= 0.0) break;
	    par[wh] = nPar;
	    labs[wh] = nType;
	    isChild = calcChilds(par);
	    //System.out.println(max + " " + wh + " " + nPar + " " + nType);
	}
    }
}

{'fraction_non_alphanumeric': 0.20985915492957746, 'fraction_numerical': 0.023591549295774648, 'mean_word_length': 3.2458893871449925, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 7, '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': '6955656', 'n_tokens_mistral': 2724, 'n_tokens_neox': 2479, 'n_words': 473}