Example #1
0
        /// <summary>
        /// creates the token list from the file at pathToFile
        /// </summary>
        /// <param name="pathToFile"></param>
        /// <param name="referenceData"></param>
        public ComparisonModel(string pathToFile, IEnumerable <SourceEntityData> referenceData)
        {
            ReferenceData = referenceData;
            var factory = new MutexTokenFactory();

            Tokens = factory.GetTokenWrapperListFromSource(pathToFile);
        }
Example #2
0
        /// <summary>
        /// calculates the maximum similarity of the provided source against
        /// all sources for the given asignment in the reference database
        /// </summary>
        /// <param name="student"></param>
        /// <param name="assignment"></param>
        /// <param name="source"></param>
        public void Start(string student, string assignment, string source)
        {
            cLogger.DebugFormat("starting with threshold {0}", Threshold);
            TokenFactory factory = new MutexTokenFactory();

            var tokens = factory.GetTokenWrapperListFromSource(source);

            //LexerHelper.CreateLexerFromSource(source).GetTokenWrappers().ToList();
            cLogger.Debug("tokenized source... loading Data Repository");
            var repo = Repository.GetRepository();

            comparisonModel = new ComparisonModel(tokens, repo.LoadByAssignment(assignment), factory);

            comparisonModel.Calculate();

            var sourceEntityData = new SourceEntityData(student, assignment, tokens.ToStringEnumerable(), source);

            repo.Store(sourceEntityData, MaximumSimilarity < Threshold);
        }
Example #3
0
        public void ANTLRITokenVersusMutexTokenImpl()
        {
            var factory = new MutexTokenFactory();
            var itokens = factory.GetTokenWrapperListFromSource("void main(int argc, char** argv)").ToGSTTokenList();

            var tokennames  = new[] { "VOID", "IDENTIFIER", "INTEGER_DATATYPE", "IDENTIFIER", "POINTER_DATATYPE", "IDENTIFIER" };
            var mutextokens = factory.GetTokenWrapperEnumerable(tokennames).ToGSTTokenList();

            for (int i = 0; i < itokens.Count; i++)
            {
                Assert.AreEqual(itokens[i].GetHashCode(), mutextokens[i].GetHashCode());
            }

            var algo = new HashingGSTAlgorithm <GSTToken <TokenWrapper> >(itokens, mutextokens)
            {
                MinimumMatchLength = 3
            };

            algo.RunToCompletion();


            Assert.AreEqual(100, algo.Similarity);
        }