private Bigram GetMaxBigramByStepBS(int step, bool vocal) { //Get max bigram Random rng = new Random(); Bigram current = new Bigram(step, '-', '-', 0.0); foreach (Bigram element in bigramTable[step]) { if ((vocal == EsVocal(element.w1)) || (!vocal == !EsVocal(element.w1))) { if (current.weight < element.weight) { current = element; } else if (current.weight == element.weight) { if (rng.Next(10) < 5) { current = element; } } } } return(current); }
private Bigram GetMaxBigramByStep(int step) { //Get max bigram Random rng = new Random(); Bigram current = bigramTable[step][0]; foreach (Bigram element in bigramTable[step]) { if (element.weight > current.weight) { current = element; } else { if (element.weight == current.weight) { if (rng.Next(10) < 5) { current = element; } } } } return(current); }
public String WordGenerationUsingBigramsSequential() { String palabra = ""; Bigram bigrama = GetMaxBigramByStep(0); palabra += bigrama.w1; palabra = AuxWordGenerationSequential(palabra, 1, bigrama.weight); return(palabra); }
public String WordGenerationUsingBigramsSequentialBS() { String palabra = ""; Bigram bigrama = GetMaxBigramByStepBS(0, binaryStructure[0] == "v"); if (bigrama.w1 == '-') { return("not found"); } palabra += bigrama.w1; palabra = AuxWordGenerationSequentialBS(palabra, 1, bigrama.weight); return(palabra); }
private String AuxWordGenerationSequential(String palabra, int step, Double currentWeight) { if (step + 1 <= averageLength) { Bigram bigrama = GetMaxBigramByStep(step); palabra += bigrama.w1; return(AuxWordGenerationSequential(palabra, step + 1, currentWeight + bigrama.weight)); } else { return(palabra); } }
private String AuxWordGenerationSequentialBS(String palabra, int step, Double currentWeight) { if (step + 1 <= averageLength) { Bigram bigrama = GetMaxBigramByStepBS(step, binaryStructure[step] == "v"); if (bigrama.w1 == '-') { return("not found"); } palabra += bigrama.w1; return(AuxWordGenerationSequentialBS(palabra, step + 1, currentWeight + bigrama.weight)); } else { return(palabra); } }
public bool Compare(Bigram obj) { return((this.w1 == obj.w1) & (this.w0 == obj.w0)); }
private static bool Compare(Bigram obj0, Bigram obj1) { return((obj0.w0 == obj1.w1) & (obj0.w0 == obj1.w0)); }