FreeLing
4.0
|
Class to handle loading a config file for freeling module, with XML-like sections. More...
#include <configfile.h>
Public Member Functions | |
config_file (bool skip=false, const std::wstring &comment=L"##") | |
Class to handle loading a config file for freeling module, with XML-like sections. | |
~config_file () | |
void | add_section (const std::wstring &key, int section, bool required=false) |
bool | open (const std::wstring &fname) |
void | close () |
bool | get_content_line (std::wstring &line) |
int | get_section () const |
int | get_line_num () const |
bool | at_section_start () const |
Private Member Functions | |
bool | isopensection (const std::wstring &s) const |
bool | isclosesection (const std::wstring &s) const |
bool | iscomment (const std::wstring &s) const |
Private Attributes | |
std::map< std::wstring, int > | sectionsopen |
std::map< std::wstring, int > | sectionsclose |
std::set< std::wstring > | requiredsections |
std::wifstream | filestr |
int | section |
std::wstring | filename |
bool | section_start |
std::wstring | comment_prefix |
int | line_num |
bool | skip_unknown_sections |
std::wstring | unk_name |
Static Private Attributes | |
static const int | SECTION_NONE = -1 |
static const int | SECTION_UNKNOWN = -2 |
Class to handle loading a config file for freeling module, with XML-like sections.
freeling::config_file::config_file | ( | bool | skip = false , |
const std::wstring & | comment = L"##" |
||
) |
Class to handle loading a config file for freeling module, with XML-like sections.
----------------------------------------- Constructor
----------------------------------------- Destructor
void freeling::config_file::add_section | ( | const std::wstring & | key, |
int | section, | ||
bool | required = false |
||
) |
----------------------------------------- add a section with corresponding open/close label. if required, crash when the file does not contain it
References requiredsections, sectionsclose, and sectionsopen.
Referenced by freeling::alternatives::alternatives(), freeling::bioner::bioner(), freeling::compounds::compounds(), freeling::dictionary::dictionary(), freeling::hmm_tagger::hmm_tagger(), freeling::locutions::locutions(), freeling::nec::nec(), freeling::ner::ner(), freeling::ner_module::ner_module(), freeling::np::np(), freeling::phonetics::phonetics(), freeling::probabilities::probabilities(), freeling::semanticDB::semanticDB(), freeling::senses::senses(), freeling::smoothingLD< std::wstring, wchar_t >::smoothingLD(), freeling::splitter::splitter(), freeling::tagset::tagset(), freeling::tokenizer::tokenizer(), and freeling::ukb::ukb().
bool freeling::config_file::at_section_start | ( | ) | const |
---------------------------------------- get whether current line is first in its section
References section_start.
Referenced by freeling::phonetics::phonetics().
void freeling::config_file::close | ( | ) |
----------------------------------------- close stream
References filestr.
Referenced by freeling::alternatives::alternatives(), freeling::bioner::bioner(), freeling::compounds::compounds(), freeling::dictionary::dictionary(), freeling::hmm_tagger::hmm_tagger(), freeling::locutions::locutions(), freeling::nec::nec(), freeling::ner::ner(), freeling::ner_module::ner_module(), freeling::np::np(), freeling::phonetics::phonetics(), freeling::probabilities::probabilities(), freeling::semanticDB::semanticDB(), freeling::senses::senses(), freeling::smoothingLD< std::wstring, wchar_t >::smoothingLD(), freeling::splitter::splitter(), freeling::tagset::tagset(), freeling::tokenizer::tokenizer(), and freeling::ukb::ukb().
bool freeling::config_file::get_content_line | ( | std::wstring & | line | ) |
----------------------------------------- process next line, handling section opening and closing. returns only content lines
References ERROR_CRASH, filename, filestr, isclosesection(), iscomment(), isopensection(), line_num, requiredsections, section, SECTION_NONE, section_start, SECTION_UNKNOWN, sectionsclose, sectionsopen, skip_unknown_sections, TRACE, unk_name, and WARNING.
Referenced by freeling::alternatives::alternatives(), freeling::bioner::bioner(), freeling::compounds::compounds(), freeling::dictionary::dictionary(), freeling::hmm_tagger::hmm_tagger(), freeling::locutions::locutions(), freeling::nec::nec(), freeling::ner::ner(), freeling::ner_module::ner_module(), freeling::np::np(), freeling::phonetics::phonetics(), freeling::probabilities::probabilities(), freeling::semanticDB::semanticDB(), freeling::senses::senses(), freeling::smoothingLD< std::wstring, wchar_t >::smoothingLD(), freeling::splitter::splitter(), freeling::tagset::tagset(), freeling::tokenizer::tokenizer(), and freeling::ukb::ukb().
int freeling::config_file::get_line_num | ( | ) | const |
---------------------------------------- get current line number
References line_num.
int freeling::config_file::get_section | ( | ) | const |
----------------------------------------- get current section
References section.
Referenced by freeling::alternatives::alternatives(), freeling::bioner::bioner(), freeling::compounds::compounds(), freeling::dictionary::dictionary(), freeling::hmm_tagger::hmm_tagger(), freeling::locutions::locutions(), freeling::nec::nec(), freeling::ner::ner(), freeling::ner_module::ner_module(), freeling::np::np(), freeling::phonetics::phonetics(), freeling::probabilities::probabilities(), freeling::semanticDB::semanticDB(), freeling::senses::senses(), freeling::smoothingLD< std::wstring, wchar_t >::smoothingLD(), freeling::splitter::splitter(), freeling::tagset::tagset(), freeling::tokenizer::tokenizer(), and freeling::ukb::ukb().
bool freeling::config_file::isclosesection | ( | const std::wstring & | s | ) | const [private] |
----------------------------------------- See if a line is a section closing
Referenced by get_content_line().
bool freeling::config_file::iscomment | ( | const std::wstring & | s | ) | const [private] |
----------------------------------------- See if a line is a comment or an empty/blank line
References comment_prefix.
Referenced by get_content_line().
bool freeling::config_file::isopensection | ( | const std::wstring & | s | ) | const [private] |
----------------------------------------- See if a line is a section opening
Referenced by get_content_line().
bool freeling::config_file::open | ( | const std::wstring & | fname | ) |
----------------------------------------- open config file
References filename, filestr, line_num, freeling::util::open_utf8_file(), section, SECTION_NONE, and section_start.
Referenced by freeling::alternatives::alternatives(), freeling::bioner::bioner(), freeling::compounds::compounds(), freeling::dictionary::dictionary(), freeling::hmm_tagger::hmm_tagger(), freeling::locutions::locutions(), freeling::nec::nec(), freeling::ner::ner(), freeling::ner_module::ner_module(), freeling::np::np(), freeling::phonetics::phonetics(), freeling::probabilities::probabilities(), freeling::semanticDB::semanticDB(), freeling::senses::senses(), freeling::smoothingLD< std::wstring, wchar_t >::smoothingLD(), freeling::splitter::splitter(), freeling::tagset::tagset(), freeling::tokenizer::tokenizer(), and freeling::ukb::ukb().
std::wstring freeling::config_file::comment_prefix [private] |
Referenced by iscomment().
std::wstring freeling::config_file::filename [private] |
Referenced by get_content_line(), and open().
std::wifstream freeling::config_file::filestr [private] |
Referenced by close(), get_content_line(), and open().
int freeling::config_file::line_num [private] |
Referenced by get_content_line(), get_line_num(), and open().
std::set<std::wstring> freeling::config_file::requiredsections [private] |
Referenced by add_section(), and get_content_line().
int freeling::config_file::section [private] |
Referenced by get_content_line(), get_section(), and open().
const int freeling::config_file::SECTION_NONE = -1 [static, private] |
Referenced by get_content_line(), and open().
bool freeling::config_file::section_start [private] |
Referenced by at_section_start(), get_content_line(), and open().
const int freeling::config_file::SECTION_UNKNOWN = -2 [static, private] |
Referenced by get_content_line().
std::map<std::wstring,int> freeling::config_file::sectionsclose [private] |
Referenced by add_section(), and get_content_line().
std::map<std::wstring,int> freeling::config_file::sectionsopen [private] |
Referenced by add_section(), and get_content_line().
bool freeling::config_file::skip_unknown_sections [private] |
Referenced by get_content_line().
std::wstring freeling::config_file::unk_name [private] |
Referenced by get_content_line().