SHARE
TWEET

Untitled

a guest Feb 14th, 2015 272 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef fst::StdVectorFst GRAPH;
  2. GRAPH _graph1,  _graph2;
  3. //...
  4. typedef fst::LabelLookAheadMatcher<fst::SortedMatcher<GRAPH>, fst::olabel_lookahead_flags> LOOK_MATCHER;
  5. typedef fst::SortedMatcher<GRAPH> SORTED_MATCHER;
  6. typedef fst::SequenceComposeFilter<LOOK_MATCHER, SORTED_MATCHER> SEQ_FILTER;
  7. typedef fst::LookAheadComposeFilter<SEQ_FILTER, LOOK_MATCHER, SORTED_MATCHER, fst::MATCH_OUTPUT> LOOK_COMPOSE_FILTER;
  8. typedef fst::PushWeightsComposeFilter<LOOK_COMPOSE_FILTER, LOOK_MATCHER, SORTED_MATCHER, fst::MATCH_OUTPUT> PUSH_WEIGHTS_FILTER;
  9. typedef fst::PushLabelsComposeFilter<PUSH_WEIGHTS_FILTER, LOOK_MATCHER, SORTED_MATCHER, fst::MATCH_OUTPUT> PUSH_LABELS_FILTER;
  10.  
  11. typedef PUSH_LABELS_FILTER COMPOSE_FILTER;
  12.  
  13. // My compose options
  14. fst::CacheOptions cacheOptions;
  15. fst::ComposeFstImplOptions<LOOK_MATCHER, SORTED_MATCHER, COMPOSE_FILTER> composeOptions(cacheOptions);
  16. composeOptions.matcher1 = new LOOK_MATCHER(_graph1, fst::MATCH_OUTPUT);
  17.  
  18. //Relabel _graph1 such as fst::StdOLabelLookAheadFst graph1Look(_graph1);
  19. LOOK_MATCHER::MatcherData* matcherData = composeOptions.matcher1->GetData();
  20. fst::LabelReachable<Arc> graph1Reachable(matcherData);
  21. std::auto_ptr<GRAPH> graph1Relabeled(&_graph1);
  22. graph1Reachable.Relabel(graph1Relabeled.get(), false);
  23. graph1Relabeled->SetInputSymbols(NULL);
  24.  
  25. //Relabel _graph2 such as fst::LabelLookAheadRelabeler<GRAPH::Arc>::Relabel(graph2TrueRelabel.get(), graph1Look, true);
  26. fst::LabelReachable<Arc> graph2Reachable(matcherData);
  27. std::auto_ptr<GRAPH> graph2Relabeled(&_graph2);
  28. graph2Reachable.Relabel(graph2Relabeled.get(), true);
  29.  
  30. fst::ArcSort(graph2Relabeled.get(), fst::StdILabelCompare());
  31.  
  32. composeOptions.matcher2 = new SORTED_MATCHER(*graph2Relabeled.get(), fst::MATCH_INPUT);
  33. composeOptions.filter = new COMPOSE_FILTER(*graph1Relabeled.get(), *graph2Relabeled.get(), composeOptions.matcher1, composeOptions.matcher2);
  34.  
  35. std::auto_ptr<GRAPH> composedRes(new GRAPH);
  36. *composedRes = fst::ComposeFst<Arc>(*graph1Relabeled.get(), *graph2Relabeled.get(), composeOptions);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top