Add debugging helpers to PathTrie
This commit is contained in:
parent
83a89dcae6
commit
31d81740ee
@ -33,8 +33,8 @@ bindings: clean-keep-common
|
||||
|
||||
bindings-debug: clean-keep-common
|
||||
pip install --quiet $(PYTHON_PACKAGES) wheel==0.31.0 setuptools==39.1.0
|
||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --debug --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS) -DDEBUG" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --debug --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||
$(GENERATE_DEBUG_SYMS)
|
||||
find temp_build -type f -name "*.o" -delete
|
||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS) -DDEBUG" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||
rm -rf temp_build
|
||||
|
@ -11,7 +11,7 @@ from multiprocessing.dummy import Pool
|
||||
|
||||
ARGS = ['-DKENLM_MAX_ORDER=6', '-std=c++11', '-Wno-unused-local-typedefs', '-Wno-sign-compare']
|
||||
OPT_ARGS = ['-O3', '-DNDEBUG']
|
||||
DBG_ARGS = ['-O0', '-g', '-UNDEBUG']
|
||||
DBG_ARGS = ['-O0', '-g', '-UNDEBUG', '-DDEBUG']
|
||||
|
||||
INCLUDES = [
|
||||
'..',
|
||||
|
@ -174,3 +174,31 @@ void PathTrie::set_dictionary(PathTrie::FstType* dictionary) {
|
||||
void PathTrie::set_matcher(std::shared_ptr<fst::SortedMatcher<FstType>> matcher) {
|
||||
matcher_ = matcher;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void PathTrie::vec(std::vector<PathTrie*>& out) {
|
||||
if (parent != nullptr) {
|
||||
parent->vec(out);
|
||||
}
|
||||
out.push_back(this);
|
||||
}
|
||||
|
||||
void PathTrie::print(const Alphabet& a) {
|
||||
std::vector<PathTrie*> chain;
|
||||
vec(chain);
|
||||
std::string tr;
|
||||
printf("characters:\t ");
|
||||
for (PathTrie* el : chain) {
|
||||
printf("%X ", el->character);
|
||||
if (el->character != ROOT_) {
|
||||
tr.append(a.StringFromLabel(el->character));
|
||||
}
|
||||
}
|
||||
printf("\ntimesteps:\t ");
|
||||
for (PathTrie* el : chain) {
|
||||
printf("%d ", el->timestep);
|
||||
}
|
||||
printf("\n");
|
||||
printf("transcript:\t %s\n", tr.c_str());
|
||||
}
|
||||
#endif // DEBUG
|
@ -9,6 +9,10 @@
|
||||
|
||||
#include "fst/fstlib.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "alphabet.h"
|
||||
#endif
|
||||
|
||||
/* Trie tree for prefix storing and manipulating, with a dictionary in
|
||||
* finite-state transducer for spelling correction.
|
||||
*/
|
||||
@ -44,6 +48,11 @@ public:
|
||||
// remove current path from root
|
||||
void remove();
|
||||
|
||||
#ifdef DEBUG
|
||||
void vec(std::vector<PathTrie*>& out);
|
||||
void print(const Alphabet& a);
|
||||
#endif // DEBUG
|
||||
|
||||
float log_prob_b_prev;
|
||||
float log_prob_nb_prev;
|
||||
float log_prob_b_cur;
|
||||
|
Loading…
Reference in New Issue
Block a user