Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public String WordGenerationUsingBigramsSequential()
        {
            String palabra = "";
            Bigram bigrama = GetMaxBigramByStep(0);

            palabra += bigrama.w1;
            palabra  = AuxWordGenerationSequential(palabra, 1, bigrama.weight);
            return(palabra);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 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);
     }
 }
Exemple #6
0
 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));
 }