Package joshua.decoder.ff

Examples of joshua.decoder.ff.FeatureFunction


    //????????
   
    Map<String,Integer> rulesIDTable = null; //TODO??
 
    //TODO
    FeatureFunction rerankFF = DiscriminativeSupport.setupRerankingFeature(featID, weight, symbolTbl, useTMFeat, useLMFeat, useEdgeNgramOnly, useTMTargetFeat,
        JoshuaConfiguration.useMicroTMFeat, JoshuaConfiguration.wordMapFile,
        ngramStateID,
        baselineLMOrder, startNgramOrder, endNgramOrder, featureFile, modelFile, rulesIDTable);
   
    features.add(rerankFF);
View Full Code Here


    if(featFunctions.size()!=weight_vector.length){
      System.out.println("In updateFeatureWeightVector: number of weights does not match number of feature functions");
      System.exit(0);
    }   
    for(int i=0; i<featFunctions.size(); i++){
      FeatureFunction ff = featFunctions.get(i);
      double old_weight = ff.getWeight();
      ff.setWeight(weight_vector[i]);
      System.out.println("Feature function : " + ff.getClass().getSimpleName() + "; weight changed from " + old_weight + " to " + ff.getWeight());
    }
  }
View Full Code Here

        String[] fds = line.split("\\s+");
        if (fds[0].compareTo("vbaseline") == 0 && fds.length == 2) {
          //baseline feature
          double baselineWeight = new Double(fds[1].trim());
         
          FeatureFunction ff =  new EdgeTblBasedBaselineFF(ngramStateID+1+featFunctions.size(), baselineWeight);         
          featFunctions.add(ff);
          logger.info(String.format("Baseline feature wiht weight: " + baselineWeight));       
         
        }else if (fds[0].compareTo("vbaselinecombo") == 0 && fds.length > 2) {
          //baseline combo features: vbaselinecombo list-of-baseline-features (each one should be " pos_id||inter-weight ") weight
          double weight = new Double(fds[fds.length-1].trim());
          List<Integer> positions = new ArrayList<Integer>();
          List<Double> interWeights = new ArrayList<Double>();
          for(int i=1; i<fds.length-1; i++){
            String[] tems = fds[i].split("\\|{2}");
            int pos = new Integer(tems[0]);
            double interWeight = new Double(tems[1]);
            positions.add(pos);
            interWeights.add(interWeight);
          }
          System.out.println("baseline combo model");
          FeatureFunction ff =  new BaselineComboFF(ngramStateID+1+featFunctions.size(), weight, positions, interWeights);
          featFunctions.add(ff);
          logger.info( String.format("Baseline combo model with weight: " + weight));   
         
        }else if(fds[0].compareTo("vconstituent") == 0 && fds.length == 2) {
          /*
          double constituentWeight = new Double(fds[1].trim());         
          HashMap<HyperEdge,Double> tbl = new HashMap<HyperEdge,Double>();
          FeatureFunction ff =  new BaselineFF(baselineLMFeatID+1+featFunctions.size(), constituentWeight, tbl);
          FeatureTemplate ft  = new FeatureTemplateConstituent();   
          VariationalLMApproximator rmodel = new VariationalLMApproximator(ff, ft, tbl);
          featFunctions.add(ff);
          approximatorMap.add(rmodel);
          
          logger.info( String.format("constituent model with weight: " + constituentWeight)); 
          */
          logger.severe("Wrong config line: " + line);
          System.exit(1);
        } else if(fds[0].compareTo("vlm")==&& fds.length == 3){
          int vlmOrder = new Integer(fds[1].trim());
          if(vlmOrder> baselineLMOrder){
            System.out.println("varatioanl_ngram_order is greater than baseline_lm_order; must be wrong");
            System.exit(1);
          }
          double weight = new Double(fds[2].trim());         
          FeatureTemplate ft = new NgramFT(symbolTbl, true , ngramStateID, baselineLMOrder, vlmOrder, vlmOrder);
          FeatureTemplateBasedFF ff =  new FeatureTemplateBasedFF(ngramStateID+1+featFunctions.size(), weight, ft);
         
          VariationalNgramApproximator rmodel = new VariationalNgramApproximator(symbolTbl, ft, 1.0, vlmOrder);
          featFunctions.add(ff);
          approximatorMap.put(rmodel, ff);         
          logger.info( String.format("vlm feature with weight: " + weight))
         
        }else if(fds[0].compareTo("word_penalty_weight") == 0 && fds.length == 2) {
          double weight = new Double(fds[1].trim());
          System.out.println("word penalty feature");
          FeatureFunction ff =  new WordPenaltyFF(ngramStateID+1+featFunctions.size(), weight);
          featFunctions.add(ff);         
          logger.info( String.format("word penalty feature with weight: " + weight));
         
        }else{
          if (logger.isLoggable(Level.SEVERE))
View Full Code Here

      JoshuaConfiguration.include_align_index,
      JoshuaConfiguration.add_combined_cost,
      false, (oracleFile==null));
   
    if (JoshuaConfiguration.save_disk_hg) {
      FeatureFunction languageModel = null;
      for (FeatureFunction ff : this.featureFunctions) {
        if (ff instanceof LanguageModelFF) {
          languageModel = ff;
                                            //break;
        }
      }
      int lmFeatID = -1;
      if (null == languageModel) {
        logger.warning("No language model feature function found, but save disk hg");
      }else{
        lmFeatID = languageModel.getFeatureID();
      }
     
      this.hypergraphSerializer = new DiskHyperGraph(
          this.symbolTable,
          lmFeatID,
View Full Code Here

    int featID = 999;
    double weight = 1.0;
    HashSet<String> restrictedFeatureSet = null;
    HashMap<String, Double> modelTbl = obtainModelTable(this.featureStringToIntegerMap, this.lastWeightVector);
    //System.out.println("modelTable: " + modelTbl);
    FeatureFunction ff = new FeatureTemplateBasedFF(featID, weight, modelTbl, this.featTemplates, restrictedFeatureSet);

    //==== reranker
    List<FeatureFunction> features =  new ArrayList<FeatureFunction>();
    features.add(ff);
    HGRanker reranker = new HGRanker(features)
View Full Code Here

TOP

Related Classes of joshua.decoder.ff.FeatureFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.