示例#1
0
def RunReRank(config, FileData):
    print("4 Create Query DataList")
    genqueries = GenerateQueryClass.GenerateQueries()
    #print(FileData)
    reRankQueries = genqueries.generateQueriesExcelData(
        FileData, config["collection"], config["requestHandler"],
        config["solrFeatureStoreName"], config["efiParams"],
        config["QueryColums"])

    print("5 Running Solr queries to extract features")
    solrcmd = ExcuteSolrCommand.ExcuteSolr()
    fvGenerator = solrcmd.generateTrainingData(reRankQueries, config["host"],
                                               config["port"], config)
    formatter = libsvm_formatter.LibSvmFormatter()
    formatter.processQueryDocFeatureVector(fvGenerator, config["trainingFile"])
    print("6 Training model using '" + config["trainingLibraryLocation"] +
          " " + config["trainingLibraryOptions"] + "'")
    libsvm_formatter.trainLibSvm(config["trainingLibraryLocation"],
                                 config["trainingLibraryOptions"],
                                 config["trainingFile"],
                                 config["trainedModelFile"])
    print("7 Converting trained model (" + config["trainedModelFile"] +
          ") to solr model (" + config["solrModelFile"] + ")")
    formatter.convertLibSvmModelToLtrModel(config["trainedModelFile"],
                                           config["solrModelFile"],
                                           config["solrModelName"],
                                           config["solrFeatureStoreName"])
    print("8 Uploading model (" + config["solrModelFile"] + ") to Solr")
    solrcmd.uploadModel(config["collection"], config["host"], config["port"],
                        config["solrModelFile"], config["solrModelName"])
    print("------------------------END----------------------------")
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = OptionParser(usage="usage: %prog [options] ", version="%prog 1.0")
    parser.add_option('-c',
                      '--config',
                      dest='configFile',
                      help='File of configuration for the test')
    (options, args) = parser.parse_args()

    if options.configFile == None:
        parser.print_help()
        return 1

    with open(options.configFile) as configFile:
        config = json.load(configFile)

        print "Uploading features (" + config["solrFeaturesFile"] + ") to Solr"
        setupSolr(config["collection"], config["host"], config["port"],
                  config["solrFeaturesFile"], config["solrFeatureStoreName"])

        print "Converting user queries (" + config[
            "userQueriesFile"] + ") into Solr queries for feature extraction"
        reRankQueries = generateQueries(config["userQueriesFile"],
                                        config["collection"],
                                        config["requestHandler"],
                                        config["solrFeatureStoreName"],
                                        config["efiParams"])

        print "Running Solr queries to extract features"
        fvGenerator = generateTrainingData(reRankQueries, config["host"],
                                           config["port"])
        formatter = libsvm_formatter.LibSvmFormatter()
        formatter.processQueryDocFeatureVector(fvGenerator,
                                               config["trainingFile"])

        print "Training model using '" + config[
            "trainingLibraryLocation"] + " " + config[
                "trainingLibraryOptions"] + "'"
        libsvm_formatter.trainLibSvm(config["trainingLibraryLocation"],
                                     config["trainingLibraryOptions"],
                                     config["trainingFile"],
                                     config["trainedModelFile"])

        print "Converting trained model (" + config[
            "trainedModelFile"] + ") to solr model (" + config[
                "solrModelFile"] + ")"
        formatter.convertLibSvmModelToLtrModel(config["trainedModelFile"],
                                               config["solrModelFile"],
                                               config["solrModelName"],
                                               config["solrFeatureStoreName"])

        print "Uploading model (" + config["solrModelFile"] + ") to Solr"
        uploadModel(config["collection"], config["host"], config["port"],
                    config["solrModelFile"], config["solrModelName"])
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = OptionParser(usage="usage: %prog [options] ", version="%prog 1.0")
    parser.add_option('-c',
                      '--config',
                      dest='configFile',
                      help='File of configuration for the test')
    (options, args) = parser.parse_args()

    if options.configFile == None:
        parser.print_help()
        return 1

    with open(options.configFile) as configFile:
        config = json.load(configFile)

        print "Uploading feature space to Solr"
        setupSolr(config)

        print "Generating feature extraction Solr queries"
        reRankQueries = generateQueries(config)

        print "Extracting features"
        fvGenerator = generateTrainingData(reRankQueries, config)
        formatter = libsvm_formatter.LibSvmFormatter()
        formatter.processQueryDocFeatureVector(fvGenerator,
                                               config["trainingFile"])

        print "Training ranksvm model"
        libsvm_formatter.trainLibSvm(config["trainingLibraryLocation"],
                                     config["trainingFile"])

        print "Converting ranksvm model to solr model"
        formatter.convertLibSvmModelToLtrModel(
            config["trainingFile"] + ".model", config["solrModelFile"],
            config["solrModelName"])

        print "Uploading model to solr"
        uploadModel(config["collection"], config["host"], config["port"],
                    config["solrModelFile"])
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = OptionParser(usage="usage: %prog [options] ", version="%prog 1.0")
    parser.add_option('-c', '--config',
                      dest='configFile',
                      help='File of configuration for the test')
    (options, args) = parser.parse_args()

    if options.configFile == None:
        parser.print_help()
        return 1

    with open(options.configFile) as configFile:
        config = json.load(configFile)

        print "Uploading features ("+config["solrFeaturesFile"]+") to Solr"
        setupSolr(config["collection"], config["host"], config["port"], config["solrFeaturesFile"], config["solrFeatureStoreName"])

        print "Converting user queries ("+config["userQueriesFile"]+") into Solr queries for feature extraction"
        reRankQueries = generateQueries(config["userQueriesFile"], config["collection"], config["requestHandler"], config["solrFeatureStoreName"], config["efiParams"])

        print "Running Solr queries to extract features"
        fvGenerator = generateTrainingData(reRankQueries, config["host"], config["port"])
        formatter = libsvm_formatter.LibSvmFormatter();
        formatter.processQueryDocFeatureVector(fvGenerator,config["trainingFile"]);

        print "Training model using '"+config["trainingLibraryLocation"]+" "+config["trainingLibraryOptions"]+"'"
        libsvm_formatter.trainLibSvm(config["trainingLibraryLocation"],config["trainingLibraryOptions"],config["trainingFile"],config["trainedModelFile"])

        print "Converting trained model ("+config["trainedModelFile"]+") to solr model ("+config["solrModelFile"]+")"
        formatter.convertLibSvmModelToLtrModel(config["trainedModelFile"], config["solrModelFile"], config["solrModelName"], config["solrFeatureStoreName"])

        print "Uploading model ("+config["solrModelFile"]+") to Solr"
        uploadModel(config["collection"], config["host"], config["port"], config["solrModelFile"], config["solrModelName"])
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = OptionParser(usage="usage: %prog [options] ", version="%prog 1.0")
    parser.add_option('-c', '--config',
                      dest='configFile',
                      help='File of configuration for the test')
    (options, args) = parser.parse_args()

    if options.configFile == None:
        parser.print_help()
        return 1

    with open(options.configFile) as configFile:
        config = json.load(configFile)

        print "Uploading feature space to Solr"
        setupSolr(config)

        print "Generating feature extraction Solr queries"
        reRankQueries = generateQueries(config)

        print "Extracting features"
        fvGenerator = generateTrainingData(reRankQueries, config);
        formatter = libsvm_formatter.LibSvmFormatter();
        formatter.processQueryDocFeatureVector(fvGenerator,config["trainingFile"]);

        print "Training ranksvm model"
        libsvm_formatter.trainLibSvm(config["trainingLibraryLocation"],config["trainingFile"])

        print "Converting ranksvm model to solr model"
        formatter.convertLibSvmModelToLtrModel(config["trainingFile"] + ".model", config["solrModelFile"], config["solrModelName"])

        print "Uploading model to solr"
        uploadModel(config["collection"], config["host"], config["port"], config["solrModelFile"])