Esempio n. 1
0
        private double getMnemonicLCS(JToken f1, JToken f2)
        {
            List <string> mnemonics1 = this.toStringList(f1["mnemonics"].ToList());
            List <string> mnemonics2 = this.toStringList(f2["mnemonics"].ToList());

            double max_length  = Math.Max(mnemonics1.Count(), mnemonics2.Count());
            double mnemonicLCS = ngram.lcs(mnemonics1, mnemonics2) / max_length;

            return(mnemonicLCS);
        }
Esempio n. 2
0
        private int[,] ngram_matrix(List <List <string> > set1, List <List <string> > set2)
        {
            int standard = set1.Count() / 2;

            int[,] matrix = new int[set1.Count(), set2.Count()];
            Ngram ngram = new Ngram();

            double count = set1[0].Count();

            for (int i = 0; i < set1.Count(); i++)
            {
                for (int j = 0; j < set2.Count(); j++)
                {
                    int lcs = ngram.lcs(set1[i], set2[j]);
                    if (lcs < (count * 0.7))
                    {
                        lcs = 0;
                    }
                    matrix[i, j] = (2 * standard) - lcs;
                }
            }
            return(matrix);
        }