Esempio n. 1
0
        private void LabelTopic_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!Directory.Exists(FileMg.AutoTopicLabelFileDir))
            {
                Directory.CreateDirectory(FileMg.AutoTopicLabelFileDir);
            }

            int minmumTopicNumber = PrepareTopicFile.GetMinimumTopicNumber();
            int maxIteration      = Int32.Parse(Configures.GetAutoWizardMaxIteration());

            if (minmumTopicNumber != -1)
            {
                string summaryFilePath   = FileMg.AutoTmtOutputFileDir + string.Format(Constants.TmtOutputSummaryFilePathTemp, maxIteration.ToString("D5"));
                string topicTermFilePath = FileMg.AutoTopicLabelFileDir + Constants.TopicTermFileName;
                PrepareTopicFile.Execute(summaryFilePath, topicTermFilePath);
                JNSPToolMg.RunJNSPTool();
                string   jnspOutputFileName = FileMg.AutoJNSPDataFileDir + Constants.JnspOptionCNTFileName + Constants.JnspOptionWindowNumber + ".cnt";
                KDDLabel kddLabel           = new KDDLabel(jnspOutputFileName, topicTermFilePath, summaryFilePath, FileMg.AutoTopicLabelFileDir + Constants.TopicLabelFileName);
                kddLabel.GenerateTopicLabel();
                TopicSim.CalTopicSimilarity(topicTermFilePath, FileMg.AutoTopicLabelFileDir + Constants.TopicSimilarityFileName);

                RToolMg.RunRTool();
            }
        }
Esempio n. 2
0
        private static bool LabelTopic(BackgroundWorker backgroundWorker)
        {
            OutputMg.OutputHeader1(backgroundWorker, "Step 4", "Label Topic");
            /* 0. Create file directory */
            if (!Directory.Exists(FileMg.AutoTopicLabelFileDir))
            {
                Directory.CreateDirectory(FileMg.AutoTopicLabelFileDir);
            }

            /* 1. Get minimum topic number */
            OutputMg.OutputContent(backgroundWorker, "Getting minimum topic number.");
            int minmumTopicNumber = PrepareTopicFile.GetMinimumTopicNumber();
            int maxIteration      = Int32.Parse(Configures.GetAutoWizardMaxIteration());

            if (minmumTopicNumber == -1)
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to get minimum topic number. Please check whether you run TMT successfully.");
                return(false);
            }

            /* 2. Run TMT */
            OutputMg.OutputContent(backgroundWorker, "Minimum topic number is " + minmumTopicNumber);
            string summaryFilePath   = FileMg.AutoTmtOutputFileDir + string.Format(Constants.TmtOutputSummaryFilePathTemp, maxIteration.ToString("D5"));
            string topicTermFilePath = FileMg.AutoTopicLabelFileDir + Constants.TopicTermFileName;

            OutputMg.OutputContent(backgroundWorker, "Start to generate topic terms file.");
            PrepareTopicFile.Execute(summaryFilePath, topicTermFilePath);
            //LabelDomainTopic.Execute(Constants.DefaultSourceFileDir, Constants.TopicLabelFileDir + Constants.TopicTermFileName, summaryFilePath, Constants.TopicLabelFileDir + Constants.TopicLabelFileName);
            if (!File.Exists(topicTermFilePath))
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to generate topic terms file.");
                return(false);
            }

            OutputMg.OutputContent(backgroundWorker, "Finished generating topic terms file.");

            /* 3. Run JNSP */
            OutputMg.OutputContent(backgroundWorker, "Start to run JNSP tool.");
            if (!Directory.Exists(FileMg.AutoJNSPDataFileDir))
            {
                Directory.CreateDirectory(FileMg.AutoJNSPDataFileDir);
            }

            JNSPToolMg.RunJNSPTool();
            string jnspOutputFileName = FileMg.AutoJNSPDataFileDir + Constants.JnspOptionCNTFileName + Constants.JnspOptionWindowNumber + ".cnt";

            if (!File.Exists(jnspOutputFileName))
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to run JNSP tool.");
                return(false);
            }

            OutputMg.OutputContent(backgroundWorker, "Finished running JNSP tool.");

            /* 4. Label topic */
            OutputMg.OutputContent(backgroundWorker, "Start to label topic.");
            KDDLabel kddLabel = new KDDLabel(jnspOutputFileName, topicTermFilePath, summaryFilePath, FileMg.AutoTopicLabelFileDir + Constants.TopicLabelFileName);

            kddLabel.GenerateTopicLabel();
            if (!File.Exists(FileMg.AutoTopicLabelFileDir + Constants.TopicLabelFileName))
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to label topic.");
                return(false);
            }

            OutputMg.OutputContent(backgroundWorker, "Finished labeling topic");

            /* 5. Generate Similarity */
            OutputMg.OutputContent(backgroundWorker, "Start to generate topic similarity.");
            TopicSim.CalTopicSimilarity(topicTermFilePath, FileMg.AutoTopicLabelFileDir + Constants.TopicSimilarityFileName);
            if (!File.Exists(FileMg.AutoTopicLabelFileDir + Constants.TopicLabelFileName))
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to generate topic similarity.");
                return(false);
            }

            OutputMg.OutputContent(backgroundWorker, "Finished generating topic similarity");
            /* 6. Running R Tool */
            OutputMg.OutputContent(backgroundWorker, "Start to generate BiTree with R tool.");
            RToolMg.RunRTool();
            if (!File.Exists(FileMg.AutoRDataFileDir + Constants.ROutputFileName))
            {
                OutputMg.OutputContent(backgroundWorker, "Failed to generate BiTree with R tool. Please make sure you have setup R tool.");
                return(false);
            }

            OutputMg.OutputContent(backgroundWorker, "Finished generating BiTree with R tool");

            return(true);
        }