示例#1
0
        /// <summary>
        /// Combines two or more precompiled document selection ranks
        /// </summary>
        /// <param name="inputNames">comma separated list of DS rank file names, leave empty if search pattern is used</param>
        /// <param name="searchPattern">file search pattern to select source files, leave * if no file search should be performed</param>
        /// <param name="compression">vector dimensions compression operation, i.e. how scores should be combined into single dimension</param>
        /// <param name="outputName">Name of the output.</param>
        /// <param name="doRankingFusion">if set to <c>true</c> [do ranking fusion].</param>
        /// <remarks>
        /// What it will do?
        /// </remarks>
        /// <seealso cref="aceOperationSetExecutorBase" />
        public void aceOperation_makeCombineDSRanks(
            [Description("Space separated list of DS rank file names, leave empty if search pattern is used")] String inputNames = " ",
            [Description("vector dimensions compression operation, i.e. how scores should be combined into single dimension")] operation compression = operation.avg,
            [Description("Name of output Document Selection Rank file. Leave * to assign name as combination of input files")] String outputName     = "*",
            [Description("If true, it will perform ranking fusion instead of simple score fusion")] Boolean doRankingFusion = true,
            [Description("file search pattern to select source files, leave * if no file search should be performed")] String searchPattern = "*"
            )
        {
            SetupDocumentSelection setup = docSelection.data.CloneViaXML();

            ProceduralFolderFor <ProcedureCreateScoreSet, SetupDocumentSelection, OperationContext, ExperimentModelExecutionContext> procedures
                = new ProceduralFolderFor <ProcedureCreateScoreSet, SetupDocumentSelection, OperationContext, ExperimentModelExecutionContext>(mainContext.folds, setup, mainContext.notes, parent);

            outputName = DocumentSelectResult.CheckAndMakeFilename(outputName);

            foreach (var p in procedures)
            {
                p.Open();


                DocumentSelectResult resultOut = new DocumentSelectResult();

                var fl = mainContext.resourceProvider.GetResourceFiles(inputNames, p.fold);

                List <DocumentSelectResult> results = DocumentRankingExtensions.LoadDSRankings(fl, p.notes);

                resultOut = results.Fusion(compression, doRankingFusion, true, p.notes);

                String pt = mainContext.resourceProvider.SetResourceFilePath(outputName, p.fold);

                resultOut.saveObjectToXML(pt);

                p.Close();
            }
        }
示例#2
0
        public override ExperimentDataSetFoldContextPair <OperationContext> Execute(ILogBuilder logger, OperationContext executionContextMain = null, ExperimentModelExecutionContext executionContextExtra = null)
        {
            ExperimentDataSetFoldContextPair <OperationContext> output = new ExperimentDataSetFoldContextPair <OperationContext>(fold, executionContextMain);

            Open();

            Boolean skip = false;

            //  String fn = setup.OutputFilename;

            String p_m = WeightDictionary.GetDictionaryFilename(setup.OutputFilename, fold_notes.folder);  //FeatureWeightModel.GetModelDefinitionFilename(setup.OutputFilename, fold_notes.folder);

            //String p_d = FeatureWeightModel.GetModelDataFilename(setup.OutputFilename, fold_notes.folder);


            if (setup.skipIfExisting)
            {
                if (File.Exists(p_m))
                {
                    logger.log("WeightTable [" + p_m + "] found, skipping the operation");
                    skip = true;
                }
            }



            if (!skip)
            {
                notes.log("Rendering primary view");

                // ------------------- PRIMARY CONTEXT

                output.context.DeployDataSet(fold, logger);

                primaryEntityOperation.TextRendering(output.context, notes);

                //primaryEntityOperation.TextPreblendFilter(output.context, notes);

                //primaryEntityOperation.TextBlending(output.context, notes);


                corpusOperation.SpaceModelPopulation(output.context, notes);

                corpusOperation.SpaceModelCategories(output.context, notes);

                corpusOperation.FeatureSelection(output.context, notes, requirements.MayUseSelectedFeatures);



                OperationContext primaryContext = output.context;

                // ------------------- SECONDARY CONTEXT

                output.context = new OperationContext();

                notes.log("Rendering secondary view");

                output.context.DeployDataSet(fold, logger);

                secondaryEntityOperation.TextRendering(output.context, notes);

                //  secondaryEntityOperation.TextPreblendFilter(output.context, notes);

                // secondaryEntityOperation.TextBlending(output.context, notes);

                corpusOperation.SpaceModelPopulation(output.context, notes);

                corpusOperation.SpaceModelCategories(output.context, notes);

                corpusOperation.FeatureSelection(output.context, notes, requirements.MayUseSelectedFeatures);


                OperationContext secondaryContext = output.context;



                ProjectionDictionary projectionPairs = DocumentRankingTools.ConstructPairDictionary(primaryContext.spaceModel.documents, secondaryContext.spaceModel.documents);

                DocumentSelectResult drmContext = output.context.PrepareContext(rankingOperation, fold_notes.folder, logger);
                drmContext             = rankingOperation.ExecuteEvaluation(drmContext, logger);
                drmContext.description = "Document score assigned to the primary text render" + name;
                drmContext.saveObjectToXML(fold_notes.folder.pathFor("DS_" + name + "_projection_score.xml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Projection within [" + name + "] operation"));

                TokenFrequencyAndScoreDictionary tokenFrequencyAndScoreDictionary = ProjectionTools.ProjectPrimaryTermsToScores(projectionPairs, drmContext, logger);

                WeightDictionary wt = tokenFrequencyAndScoreDictionary.ConstructWeightDictionary();
                wt.name        = setup.OutputFilename;
                wt.description = "Projected PrimaryView to ScoreTable - WeightTable, constructed from [" + projectionPairs.Count + "] render pairs. Document ranking: " + drmContext.description;

                wt.Save(fold_notes.folder, logger, setup.OutputFilename);

                //                wt.saveObjectToXML(p_m);
            }


            Close();

            return(output);
        }