Skip to content

Commit

Permalink
Merge branch 'master' of github.com:michalfapso/FST
Browse files Browse the repository at this point in the history
  • Loading branch information
michalfapso committed Feb 25, 2014
2 parents 2bdaa83 + 38f0177 commit 6e7f2f0
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 378 deletions.
5 changes: 3 additions & 2 deletions fst_query_features_extractor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <float.h>

#include "path_pool.h"
#include "features_generator_query.h"
#include "features_generator_path_query.h"
#include "fst_properties.h"
#include "nodes.h"
#include "path_terminator.h"
Expand Down Expand Up @@ -111,7 +111,8 @@ int main(int argc, char **argv)
PrintType pt = Path::GetPrintType();
Path::SetPrintType(PRINT_PHONEMES_ONLY);
{
FeaturesGenerator_Query<Path> features(pfeatures_out);
FeaturesGenerator_PathQuery<Path> features(pfeatures_out);
features.PrintHeader();
features.Generate(paths);
}
Path::SetPrintType(pt);
Expand Down
23 changes: 13 additions & 10 deletions fst_traverser/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "path_pool.h"
#include "forward_traverser.h"
#include "features_generator_detection.h"
#include "features_generator_path_detection.h"

#include "mlf.h"
#include "hypotheses.h"
Expand Down Expand Up @@ -95,18 +95,20 @@ int main(int argc, char **argv)
mlf::Mlf<ReferenceMlfRecord> mlf_ref(preference_mlf);
mlf::MlfRecords<ReferenceMlfRecord>* recs_ref_all_terms = mlf_ref.GetFile(putterance_filename);
mlf::MlfRecords<ReferenceMlfRecord> recs_ref;
if (!recs_ref_all_terms) {
THROW("ERROR: File '"<<putterance_filename<<"' was not found in reference MLF '"<<preference_mlf<<"'");
}
// THIS CHECKING FAILS WHEN A REFERENCE UTTERANCE HAS NO RECORD
// if (!recs_ref_all_terms) {
// THROW("ERROR: File '"<<putterance_filename<<"' was not found in reference MLF '"<<preference_mlf<<"'");
// }
// Keep only the given term in reference records
foreach(ReferenceMlfRecord* rec, *recs_ref_all_terms) {
assert(rec);
if (rec->GetWord() == (string)pterm) {
recs_ref.AddRecord(rec);
if (recs_ref_all_terms) {
foreach(ReferenceMlfRecord* rec, *recs_ref_all_terms) {
assert(rec);
if (rec->GetWord() == (string)pterm) {
recs_ref.AddRecord(rec);
}
}
}


SymbolTable* syms = NULL;
syms = SymbolTable::ReadText(psyms_filename);

Expand Down Expand Up @@ -138,7 +140,8 @@ int main(int argc, char **argv)
PrintType pt = Path::GetPrintType();
Path::SetPrintType(PRINT_PHONEMES_ONLY);
{
FeaturesGenerator_Detection<Path> features(pfeatures_out, pterm, recs_ref);
FeaturesGenerator_PathDetection<Path> features(pfeatures_out, pterm, recs_ref);
features.PrintHeader();
features.Generate(paths);
}
Path::SetPrintType(pt);
Expand Down
15 changes: 11 additions & 4 deletions include/features_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class FeaturesGenerator
{
public:
FeaturesGenerator(const std::string& outputFilename) :
mOss(outputFilename)
mOss(outputFilename),
mFieldNamePrefix("")
{}

static void SetPrintFieldNames(bool p) {msPrintFieldNames = p;}
Expand All @@ -28,13 +29,19 @@ class FeaturesGenerator
static bool msPrintFieldNames;
static bool msPrintFieldValues;
OstreamFileStdout mOss;
bool mFieldSeparator;
std::string mFieldNamePrefix;

void PrintField_begin(std::ostream& oss) {
mFieldSeparator = false;
}

template <typename T>
static void PrintField(std::ostream& oss, const std::string& name, const T& val) {
if (msPrintFieldNames) { oss << name; }
void PrintField(std::ostream& oss, const std::string& name, const T& val) {
if (mFieldSeparator) { oss << " "; } else {mFieldSeparator = true;}
if (msPrintFieldNames) { oss << mFieldNamePrefix << name; }
if (msPrintFieldNames && msPrintFieldValues) { oss << "="; }
if (msPrintFieldValues) { oss << val; }
oss << " ";
}

static bool IsHit(float startTimeSeconds, float endTimeSeconds, const mlf::MlfRecords<ReferenceMlfRecord>& recsRef) {
Expand Down
174 changes: 0 additions & 174 deletions include/features_generator_detection.h

This file was deleted.

Loading

0 comments on commit 6e7f2f0

Please sign in to comment.