Package joshua.decoder.hypergraph

Examples of joshua.decoder.hypergraph.HyperGraph


   
    DiskHyperGraph diskHG = new DiskHyperGraph(symbolTbl, ngramStateID, true, null); //have model costs stored
    diskHG.initRead(testItemsFile, testRulesFile, null);   
    for(int sent_id=0; sent_id < num_sents; sent_id ++){
      System.out.println("#Process sentence " + sent_id);
      HyperGraph testHG = diskHG.readHyperGraph();
     
      //################setup the model: including estimation of variational model
      //### step-1: run inside-outside
      //note, inside and outside will use the transition_cost of each hyperedge, this cost is already linearly interpolated
      TrivialInsideOutside insideOutsider = new TrivialInsideOutside();
View Full Code Here


  public double computeSumForString(HyperGraph hg, int sentenceID, String ref_string){
    System.out.println("Now process string: " + ref_string);
    int[] ref_sent_wrds_in = symbolTbl.addTerminals(ref_string);
   
    //### filter hypergraph
    HyperGraph filtedHG = p_filter.approximate_filter_hg(hg,ref_sent_wrds_in);
   
    //debug
    /*
    double inside_outside_scaling_factor =1.0;
    TrivialInsideOutside p_inside_outside = new TrivialInsideOutside();
View Full Code Here

    DiskHyperGraph dhg_test = new DiskHyperGraph(p_symbol, baseline_lm_feat_id, true, null); //have model costs stored
    dhg_test.initRead(f_test_items, f_test_rules,null);
     
    for(int sent_id=0; sent_id < num_sents; sent_id ++){
      System.out.println("#Process sentence " + sent_id);
      HyperGraph hg_test = dhg_test.readHyperGraph();     
      //if(sent_id==1)System.exit(1);
      //generate a unique nbest of strings based on viterbi cost
      ArrayList<String> nonUniqueNbestStrings = new ArrayList<String>();
      kbest_extractor.lazyKBestExtractOnHG(hg_test, null, topN, sent_id, nonUniqueNbestStrings);
     
View Full Code Here

    String[] referenceSentences = new String[refFileReaders.length];
    for(int i=0; i<refFileReaders.length; i++)
    referenceSentences[i]= FileUtilityOld.readLineLzf(refFileReaders[i]);
   
    //=== disk hypergraph
    HyperGraph testHG = diskHG.readHyperGraph();
   
    if(notRiskAndFeatureAnnoated){     
      if(useNoEquivAnnotator)
        return  this.riskAnnotatorNoEquiv.riskAnnotationOnHG(testHG, referenceSentences);
      else
View Full Code Here

    DefaultSemiringParser ds = new HypLenExpectation(1,0,scale);
    DiskHyperGraph dhg_test = new DiskHyperGraph(p_symbol, baseline_lm_feat_id, true, null); //have model costs stored
    dhg_test.initRead(f_dev_items, f_dev_rules,null);
    for(int sent_id=0; sent_id < num_sents; sent_id ++){
      System.out.println("#Process sentence " + sent_id);
      HyperGraph hg_test = dhg_test.readHyperGraph();     
      ds.insideEstimationOverHG(hg_test);
      CompositeSemiring goalSemiring = ds.getGoalSemiringMember(hg_test);
      goalSemiring.normalizeFactors();
      goalSemiring.printInfor();
    }   
View Full Code Here

    }
   
   
   
    /* Parsing */
    HyperGraph hypergraph = chart.expand();
   
    if (JoshuaConfiguration.visualize_hypergraph) {
      HyperGraphViewer.visualizeHypergraphInFrame(hypergraph, symbolTable);
    }
   
    if (logger.isLoggable(Level.FINER))
      logger.finer("after expand, time: "
        + ((double)(System.currentTimeMillis() - startTime) / 1000.0)
        + " seconds");
   
    if (oracleSentence != null) {
      logger.fine("Creating oracle extractor");
      OracleExtractor extractor = new OracleExtractor(this.symbolTable);
     
      logger.finer("Extracting oracle hypergraph...");
      HyperGraph oracle = extractor.getOracle(hypergraph, 3, oracleSentence);
     
      logger.finer("... Done Extracting. Getting k-best...");
      this.kbestExtractor.lazyKBestExtractOnHG(
        oracle, this.featureFunctions,
        JoshuaConfiguration.topN,
        Integer.parseInt(segment.id()), this.nbestWriter);
      logger.finer("... Done getting k-best");
     
    } else {
      /* k-best extraction */
      this.kbestExtractor.lazyKBestExtractOnHG(
        hypergraph, this.featureFunctions,
        JoshuaConfiguration.topN,
        Integer.parseInt(segment.id()), this.nbestWriter);
      if (logger.isLoggable(Level.FINER))
        logger.finer("after k-best, time: "
        + ((double)(System.currentTimeMillis() - startTime) / 1000.0)
        + " seconds");
    }
   
    if (null != this.hypergraphSerializer) {
      if(JoshuaConfiguration.use_kbest_hg){
        HyperGraph kbestHG = this.kbestExtractor.extractKbestIntoHyperGraph(hypergraph, JoshuaConfiguration.topN);
        this.hypergraphSerializer.saveHyperGraph(kbestHG);
      }else{
        this.hypergraphSerializer.saveHyperGraph(hypergraph);       
      }
    }
View Full Code Here

 
  //get the 1best tree hg, the 1-best is ranked by the split hypergraph, but the return hypergraph is in the form of the original hg 
  public HyperGraph get_1best_tree_hg(HyperGraph original_hg, HashMap g_tbl_split_virtual_items){
    VirtualItem virutal_goal_item =  get_virtual_goal_item(original_hg, g_tbl_split_virtual_items);
    HGNode onebest_goal_item = clone_item_with_best_deduction(virutal_goal_item);   
    HyperGraph res = new HyperGraph(onebest_goal_item, -1, -1, original_hg.sentID, original_hg.sentLen);//TODO: number of items/deductions
    get_1best_tree_item(virutal_goal_item, onebest_goal_item);
    return res;
  }
View Full Code Here

 
 
//  ############# construct filtered hg after runing split_hg###################
 
  public HyperGraph construct_filtered_hg(HyperGraph hg){ 
    HyperGraph hg_filtered = null;
    tbl_processed_items.clear();
    ArrayList<VirtualItem> l_virtual_items = g_tbl_split_virtual_items.get(hg.goalNode);     
    if(l_virtual_items.size()<=0){//TODO     
      System.out.println("no valid trees");
    }else{
      System.out.println("has valid trees, " + l_virtual_items.size());     
      //create a new hypergraph
      HGNode colone_goal_item = clone_item(hg.goalNode);
      hg_filtered = new HyperGraph(colone_goal_item, -1, -1, hg.sentID, hg.sentLen);
      colone_goal_item.hyperedges.clear();
      for(VirtualItem fit : l_virtual_items){
        if(fit.p_item!=hg.goalNode){System.out.println("wrong item"); System.exit(0);}
        for(VirtualDeduction fdt : fit.l_virtual_deductions){
          colone_goal_item.hyperedges.add(fdt.p_dt);
View Full Code Here

      DiskHyperGraph dhg = new DiskHyperGraph(p_symbol, baseline_lm_feat_id, saveModelCosts, null);
      dhg.initRead(f_hypergraphs, f_rule_tbl, null);
      //int total_num_sent = 5;
      for(int sent_id=0; sent_id < total_num_sent; sent_id ++){
        System.out.println("############Process sentence " + sent_id);
        HyperGraph hg = dhg.readHyperGraph();
       
        if(itemSpecific)
          g_con.itemSpecificConfusionExtraction(hg);
        else
          g_con.cellSpecificConfusionExtraction(hg,hg.sentLen);
View Full Code Here

    if(new_goal_node==null){
      System.out.println("The hypergraph has been fully filterd out, must be wrong");
      System.exit(0);
    }
    System.out.println("Finished filtering the hypergraph");
    HyperGraph filtered_hg =  new HyperGraph(new_goal_node, -1, -1, hg.sentID, hg.sentLen);
    return filtered_hg;//filtered hg
 
View Full Code Here

TOP

Related Classes of joshua.decoder.hypergraph.HyperGraph

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.