File: hfst_extensions.cpp

package info (click to toggle)
hfst 3.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,532 kB
  • sloc: cpp: 101,875; sh: 6,717; python: 5,225; yacc: 4,985; lex: 2,900; makefile: 2,017; xml: 6
file content (38 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace hfst {

  // *** Add default implementation type *** //

  hfst::ImplementationType type = hfst::TROPICAL_OPENFST_TYPE;
  void set_default_fst_type(hfst::ImplementationType t) { type = t; }
  hfst::ImplementationType get_default_fst_type() { return type; }

  std::string fst_type_to_string(hfst::ImplementationType t) { std::string retval = hfst::implementation_type_to_string(t); return retval; }

  bool is_diacritic(const std::string & symbol) { return hfst::FdOperation::is_diacritic(symbol); }

  HfstTransducer * empty_transducer()
  {
    hfst::xre::XreCompiler comp(hfst::get_default_fst_type());
    return hfst::hfst_regex(comp, "[0 - 0]", "");
  }
  HfstTransducer * copy_hfst_transducer(const hfst::HfstTransducer & t) { return new HfstTransducer(t); }
  HfstTransducer * copy_hfst_transducer_from_basic_transducer(const hfst::implementations::HfstBasicTransducer & t) { return new HfstTransducer(t, type); }
  HfstTransducer * copy_hfst_transducer_from_basic_transducer(const hfst::implementations::HfstBasicTransducer & t, hfst::ImplementationType impl) { return new HfstTransducer(t, impl); }

  hfst::HfstOutputStream * create_hfst_output_stream(const std::string & filename, hfst::ImplementationType type, bool hfst_format)
  {
    if (filename.empty()) { return new hfst::HfstOutputStream(type, hfst_format); }
    else { return new hfst::HfstOutputStream(filename, type, hfst_format); }
  }

  hfst_ol::PmatchContainer * create_pmatch_container(const std::string & filename)
  {
    std::ifstream instream(filename.c_str(),
                           std::ifstream::binary);
    if (!instream.good()) {
      return NULL;
    }
    return new hfst_ol::PmatchContainer(instream);
  }

}