Skip to content
Snippets Groups Projects
Commit c7a4d3e0 authored by Franck Dary's avatar Franck Dary
Browse files

Documented static functions

parent 3bf7b237
Branches
No related tags found
No related merge requests found
/// @file macaon_decode.cpp
/// @author Franck Dary
/// @version 1.0
/// @date 2018-08-07
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
...@@ -8,6 +13,9 @@ ...@@ -8,6 +13,9 @@
namespace po = boost::program_options; namespace po = boost::program_options;
/// @brief Get the list of mandatory and optional program arguments.
///
/// @return The lists.
po::options_description getOptionsDescription() po::options_description getOptionsDescription()
{ {
po::options_description desc("Command-Line Arguments "); po::options_description desc("Command-Line Arguments ");
...@@ -37,6 +45,13 @@ po::options_description getOptionsDescription() ...@@ -37,6 +45,13 @@ po::options_description getOptionsDescription()
return desc; return desc;
} }
/// @brief Store the program arguments inside a variables_map
///
/// @param od The description of all the possible options.
/// @param argc The number of arguments given to this program.
/// @param argv The values of arguments given to this program.
///
/// @return The variables map
po::variables_map checkOptions(po::options_description & od, int argc, char ** argv) po::variables_map checkOptions(po::options_description & od, int argc, char ** argv)
{ {
po::variables_map vm; po::variables_map vm;
...@@ -66,6 +81,12 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a ...@@ -66,6 +81,12 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a
return vm; return vm;
} }
/// @brief Uses a pre-trained TransitionMachine to predict and add information to a structured input file.
///
/// @param argc The number of arguments given to this program.
/// @param argv[] Array of arguments given to this program.
///
/// @return 0 if there was no crash.
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
auto od = getOptionsDescription(); auto od = getOptionsDescription();
......
...@@ -435,7 +435,7 @@ LOOKUP_CACHE_SIZE = 0 ...@@ -435,7 +435,7 @@ LOOKUP_CACHE_SIZE = 0
# normally produced when WARNINGS is set to YES. # normally produced when WARNINGS is set to YES.
# The default value is: NO. # The default value is: NO.
EXTRACT_ALL = NO EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation. # be included in the documentation.
...@@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO ...@@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation. # included in the documentation.
# The default value is: NO. # The default value is: NO.
EXTRACT_STATIC = NO EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO, # locally in source files will be included in the documentation. If set to NO,
...@@ -673,7 +673,7 @@ SHOW_USED_FILES = YES ...@@ -673,7 +673,7 @@ SHOW_USED_FILES = YES
# (if specified). # (if specified).
# The default value is: YES. # The default value is: YES.
SHOW_FILES = NO SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
# page. This will remove the Namespaces entry from the Quick Index and from the # page. This will remove the Namespaces entry from the Quick Index and from the
...@@ -1014,7 +1014,7 @@ STRIP_CODE_COMMENTS = YES ...@@ -1014,7 +1014,7 @@ STRIP_CODE_COMMENTS = YES
# function all documented functions referencing it will be listed. # function all documented functions referencing it will be listed.
# The default value is: NO. # The default value is: NO.
REFERENCED_BY_RELATION = NO REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES then for each documented function # If the REFERENCES_RELATION tag is set to YES then for each documented function
# all documented entities called/used by that function will be listed. # all documented entities called/used by that function will be listed.
......
...@@ -10,27 +10,140 @@ ...@@ -10,27 +10,140 @@
#include <string> #include <string>
#include <vector> #include <vector>
/// @brief Whether or not this symbol can separate words (e.g. a space).
///
/// @param c The symbol to check.
///
/// @return Whether or not this symbol can separate words.
bool isSeparator(char c); bool isSeparator(char c);
/// @brief Negation of isSeparator.
///
/// @param c The symbol to check.
///
/// @return !isSeparator(c)
bool isNotSeparator(char c); bool isNotSeparator(char c);
/// @brief Whether or not this symbol is the start of a new line (e.g. \\n).
///
/// @param c The symbol to check.
///
/// @return Whether or not this symbol is the start of a new line.
bool isNewline(char c); bool isNewline(char c);
/// @brief Get the filename of a file given it's relative or absolute path.
///
/// getFilenameFromPath(/home/toto/File.ex) = File.ex
/// @param s The path to the file.
///
/// @return The name of the file.
std::string getFilenameFromPath(const std::string & s); std::string getFilenameFromPath(const std::string & s);
/// @brief Get the number of columns a string will take when printed into a terminal.
///
/// Usefull for doing pretty prints where all is aligned.
/// @param s The string
///
/// @return The number of columns s will take when printed into a terminal.
unsigned int lengthPrinted(const std::string & s); unsigned int lengthPrinted(const std::string & s);
/// @brief Whether or not this symbol is a digit.
///
/// @param c The symbol to check.
///
/// @return Whether or not c is a digit.
bool isNum(char c); bool isNum(char c);
/// @brief Whether or not a symbol can be the end of a well-formed sentence in Natural Language.
///
/// e.g. '?', '.', '!', ...
/// @param c The symbol to check.
///
/// @return Whether or c can be the end of a well-formed sentence in NL.
bool endSentence(char c); bool endSentence(char c);
/// @brief Whether or not this symbol is the end of a line.
///
/// @param c The symbol to check.
///
/// @return Whether or not c is the end of a line.
bool endLine(char c); bool endLine(char c);
/// @brief Converts a symbol of a string to lower case.
///
/// @param s The string.
/// @param i The index of the symbol that will be set to lowercase.
void toLowerCase(std::string & s, unsigned int i); void toLowerCase(std::string & s, unsigned int i);
/// @brief Get the lower case copy of a string.
///
/// @param s The input string.
///
/// @return The lowercase copy of s.
std::string toLowerCase(std::string s); std::string toLowerCase(std::string s);
/// @brief Converts a symbol of a string to upper case.
///
/// @param s The string.
/// @param i The index of the symbol that will be set to uppercase.
void toUpperCase(std::string & s, unsigned int i); void toUpperCase(std::string & s, unsigned int i);
/// @brief Get the uppercase copy of a string.
///
/// @param s The input string.
///
/// @return The uppercase copy of s.
std::string toUpperCase(const std::string & s); std::string toUpperCase(const std::string & s);
/// @brief Get the lowercase copy of a string, removing the accents.
///
/// noAccentLower("Formaté") = "formate"
/// @param s The input string.
///
/// @return The lowercase copy of s, without accents.
std::string noAccentLower(const std::string & s); std::string noAccentLower(const std::string & s);
/// @brief Whether or not this symbol is an uppercase letter.
///
/// @param c The symbol to check.
///
/// @return Whether or not c is an uppercase letter.
bool isUpper(char c); bool isUpper(char c);
/// @brief Split a string into its substrings divided by separators.
///
/// @param s The string to split.
///
/// @return The substrings.
std::vector<std::string> split(const std::string & s); std::vector<std::string> split(const std::string & s);
/// @brief Get the transformation rule that will transform the string from to the string to.
///
/// getRule("vendaient", "vendre") = "@aient@re"\n
/// Meaning delete the suffig "aient" and add the suffix "re".
/// @param from The string to be transformed.
/// @param to The end result of the rule application to from.
///
/// @return The transformation rule that will transform from to the string to.
std::string getRule(const std::string & from, const std::string & to); std::string getRule(const std::string & from, const std::string & to);
/// @brief Whether or not a transformation rule is appliable to this specific string.
///
/// ruleIsAppliable("vendaient", "@e@a") = false\n
/// ruleIsAppliable("vendaient", "@aient@re") = true\n
/// @param from The string the rule should be applied to.
/// @param rule The transformation rule.
///
/// @return Whether or not it is possible to apply rule to from.
bool ruleIsAppliable(const std::string & from, const std::string & rule); bool ruleIsAppliable(const std::string & from, const std::string & rule);
/// @brief Apply the transformation rule to a string.
///
/// applyRule("vendaient", "@aient@re") = "vendre"
/// @param from The string to which the rule will be applied.
/// @param rule The transformation rule to apply.
///
/// @return The resulting string.
std::string applyRule(const std::string & from, const std::string & rule); std::string applyRule(const std::string & from, const std::string & rule);
/// @brief Print columns containing strings, with perfect alignment.
///
/// @param output Where to print.
/// @param cols Vector of columns.
/// @param nbSpaces The minimal number of spaces separating each columns.
void printColumns(FILE * output, const std::vector< std::vector<std::string> > & cols, int nbSpaces = 1); void printColumns(FILE * output, const std::vector< std::vector<std::string> > & cols, int nbSpaces = 1);
/// @brief Converts a float to a string, using printf's style format specifier.
///
/// float2str(0.233333, "%.2f") = "0.23"
/// @param f The float.
/// @param format How to format the float.
///
/// @return The formated string.
std::string float2str(float f, const char * format); std::string float2str(float f, const char * format);
/// @brief Macro giving informations about an error.
#define ERRINFO (getFilenameFromPath(std::string(__FILE__))+ ":l." + std::to_string(__LINE__)).c_str() #define ERRINFO (getFilenameFromPath(std::string(__FILE__))+ ":l." + std::to_string(__LINE__)).c_str()
#endif #endif
/// @file macaon_train.cpp
/// @author Franck Dary
/// @version 1.0
/// @date 2018-08-07
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
...@@ -8,6 +13,9 @@ ...@@ -8,6 +13,9 @@
namespace po = boost::program_options; namespace po = boost::program_options;
/// @brief Get the list of mandatory and optional program arguments.
///
/// @return The lists.
po::options_description getOptionsDescription() po::options_description getOptionsDescription()
{ {
po::options_description desc("Command-Line Arguments "); po::options_description desc("Command-Line Arguments ");
...@@ -44,6 +52,13 @@ po::options_description getOptionsDescription() ...@@ -44,6 +52,13 @@ po::options_description getOptionsDescription()
return desc; return desc;
} }
/// @brief Store the program arguments inside a variables_map
///
/// @param od The description of all the possible options.
/// @param argc The number of arguments given to this program.
/// @param argv The values of arguments given to this program.
///
/// @return The variables map
po::variables_map checkOptions(po::options_description & od, int argc, char ** argv) po::variables_map checkOptions(po::options_description & od, int argc, char ** argv)
{ {
po::variables_map vm; po::variables_map vm;
...@@ -73,6 +88,12 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a ...@@ -73,6 +88,12 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a
return vm; return vm;
} }
/// @brief Train a TransitionMachine to predict and add information to a structured input file, by using annotated examples.
///
/// @param argc The number of arguments given to this program.
/// @param argv[] Array of arguments given to this program.
///
/// @return 0 if there was no crash.
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
auto od = getOptionsDescription(); auto od = getOptionsDescription();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment