Esempio n. 1
0
        static void Main(string[] args)
        {
            CommandLineOption opt    = GetDefaultOption();
            Parser            parser = new Parser();
            var stopwatch            = new Stopwatch();

            try
            {
                parser.ParseArguments(args, opt);

                string[] info = File.ReadAllLines(opt.info);

                int sourceAuthorNum       = Convert.ToInt32(info[0]);
                int targetAuthorNum       = Convert.ToInt32(info[1]);
                int sourcePaperNum        = Convert.ToInt32(info[2]);
                int targetPaperNum        = Convert.ToInt32(info[3]);
                int collaborationPaperNum = Convert.ToInt32(info[4]);

                List <string> papers  = File.ReadAllLines(opt.papers).ToList();
                List <string> authors = File.ReadAllLines(opt.authors).ToList();

                var sourcePapers        = papers.Take(sourcePaperNum).ToArray();
                var targetPapers        = papers.Skip(sourcePaperNum).Take(targetPaperNum).ToArray();
                var collaborationPapers = papers.Skip(sourcePaperNum + targetPaperNum).ToArray();

                var sourceAuthors        = authors.Take(sourcePaperNum).ToArray();
                var targetAuthors        = authors.Skip(sourcePaperNum).Take(targetPaperNum).ToArray();
                var collaborationAuthors = authors.Skip(sourcePaperNum + targetPaperNum).ToArray();

                int vocabSize = 12;

                Corpora sourceCor = new Corpora(vocabSize, sourceAuthorNum);
                sourceCor.LoadDataFile(sourcePapers, sourceAuthors);
                ACTGibbsSampling sourceModel = new ACTGibbsSampling();
                sourceModel.TrainNewModel(sourceCor, opt, "outSource.txt");

                Corpora targetCor = new Corpora(vocabSize, targetAuthorNum);
                targetCor.LoadDataFile(targetPapers, targetAuthors);
                ACTGibbsSampling targetModel = new ACTGibbsSampling();
                targetModel.TrainNewModel(targetCor, opt, "outTarget.txt");

                Corpora collaborationCor = new Corpora(vocabSize, 0);
                collaborationCor.LoadDataFile(collaborationPapers, collaborationAuthors);
                CTLGibbsSampling collaborationModel = new CTLGibbsSampling(sourceModel, targetModel);
                collaborationModel.TrainNewModel(collaborationCor, opt, "outColl.txt");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }