initial commit
This commit is contained in:
commit
efcd3e1892
106 changed files with 27000 additions and 0 deletions
45
src/pfaedle/trgraph/Normalizer.h
Normal file
45
src/pfaedle/trgraph/Normalizer.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2018, University of Freiburg,
|
||||
// Chair of Algorithms and Data Structures.
|
||||
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
|
||||
|
||||
#ifndef PFAEDLE_TRGRAPH_NORMALIZER_H_
|
||||
#define PFAEDLE_TRGRAPH_NORMALIZER_H_
|
||||
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace pfaedle {
|
||||
namespace trgraph {
|
||||
|
||||
typedef std::pair<std::string, std::string> ReplRule;
|
||||
typedef std::vector<ReplRule> ReplRules;
|
||||
|
||||
typedef std::pair<std::regex, std::string> ReplRuleComp;
|
||||
typedef std::vector<ReplRuleComp> ReplRulesComp;
|
||||
|
||||
/*
|
||||
* A class for normalizing station names
|
||||
*/
|
||||
class Normalizer {
|
||||
public:
|
||||
Normalizer() {}
|
||||
explicit Normalizer(const ReplRules& rules);
|
||||
|
||||
// Normalize sn based on the rules of this normalizer
|
||||
std::string operator()(std::string sn) const;
|
||||
bool operator==(const Normalizer& b) const;
|
||||
|
||||
private:
|
||||
ReplRulesComp _rules;
|
||||
ReplRules _rulesOrig;
|
||||
mutable std::unordered_map<std::string, std::string> _cache;
|
||||
|
||||
void buildRules(const ReplRules& rules);
|
||||
};
|
||||
} // namespace trgraph
|
||||
} // namespace pfaedle
|
||||
|
||||
#endif // PFAEDLE_TRGRAPH_NORMALIZER_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue