Skip to content

Commit

Permalink
improve print pretty help message.
Browse files Browse the repository at this point in the history
  • Loading branch information
dingbin committed Feb 3, 2023
1 parent a4db8e3 commit e50a028
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 59 deletions.
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,32 @@ This FST C++ open source project Orchid-Fst has the following significant advant

```
ofst: Orchid-Fst is a smart Fst command line tool
Usage: ofst [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
-h,--help Print this help message and exit
Subcommands:
map construct fst data file from a key-value(separated with comma every line) dictionary file.
set construct fst data file from a only key(no value) dictionary file.
dot generate dot file from fst data file, which can be converted to png file using dot command like: dot -Tpng < a.dot > a.png, then you can view the picture generated.
match execute accurate match query for a term text in the fst.
prefix execute prefix query starts with a term text in the fst.
range execute range query in the fst.
fuzzy execute fuzzy query in the fst,it works by building a Levenshtein or Damerau-Levenshtein automaton within a edit distance.
map construct fst data file from a key-value(separated with comma
every line) dictionary file.
set construct fst data file from a only key(no value) dictionary
file.
dot generate dot file from fst data file, which can be converted
to png file using dot command like: dot -Tpng < a.dot > a.png,
then you can view the picture generated.
match execute accurate match query for a term text in the fst.
prefix execute prefix query starts with a term text in the fst.
range execute range query in the fst.
fuzzy execute fuzzy query in the fst,it works by building a Levenshtein
or Damerau-Levenshtein automaton within a edit distance.
Please contact dingbinthu@163.com for related questions and other matters not covered. Enjoy it!
```
Expand Down Expand Up @@ -169,3 +181,4 @@ Note: Before running the command line tool, you need to place the logger.conf lo


Please contact [dingbinthu@163.com](mailto:dingbinthu@163.com) for related questions and other matters not covered. Enjoy it.

23 changes: 23 additions & 0 deletions src/main/common/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ class TLoggerGuard {
}
};

inline string fs(const string& str, size_t column_width=60) {
assert(column_width > 0);
ostringstream oss;
size_t cur_count = 0;
for (size_t i = 0; i < str.size(); ++i) {
char c = str[i];
oss << c;
++cur_count;
if (cur_count >= column_width && !isalnum(c)) {
oss << "\n";
cur_count = 0;
while (i+1 < str.size() && isblank(str[i+1])) {
++i;
}
}
}
if (cur_count > 0) {
cur_count = 0;
oss << "\n";
}
return oss.str();
}


COMMON_END_NAMESPACE

Expand Down
Loading

0 comments on commit e50a028

Please sign in to comment.