Skip to content

Commit

Permalink
Replace > > with >>.
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldb89 committed May 13, 2013
1 parent bed260c commit fc3d47b
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 94 deletions.
6 changes: 3 additions & 3 deletions extractor/alignment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Alignment::Alignment(const string& filename) {
while (getline(infile, line)) {
vector<string> items;
boost::split(items, line, boost::is_any_of(" -"));
vector<pair<int, int> > alignment;
vector<pair<int, int>> alignment;
alignment.reserve(items.size() / 2);
for (size_t i = 0; i < items.size(); i += 2) {
alignment.push_back(make_pair(stoi(items[i]), stoi(items[i + 1])));
Expand All @@ -35,15 +35,15 @@ Alignment::Alignment() {}

Alignment::~Alignment() {}

vector<pair<int, int> > Alignment::GetLinks(int sentence_index) const {
vector<pair<int, int>> Alignment::GetLinks(int sentence_index) const {
return alignments[sentence_index];
}

void Alignment::WriteBinary(const fs::path& filepath) {
FILE* file = fopen(filepath.string().c_str(), "w");
int size = alignments.size();
fwrite(&size, sizeof(int), 1, file);
for (vector<pair<int, int> > alignment: alignments) {
for (vector<pair<int, int>> alignment: alignments) {
size = alignment.size();
fwrite(&size, sizeof(int), 1, file);
fwrite(alignment.data(), sizeof(pair<int, int>), size, file);
Expand Down
4 changes: 2 additions & 2 deletions extractor/alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Alignment {
Alignment(const string& filename);

// Returns the alignment for a given sentence.
virtual vector<pair<int, int> > GetLinks(int sentence_index) const;
virtual vector<pair<int, int>> GetLinks(int sentence_index) const;

// Writes alignment to file in binary format.
void WriteBinary(const fs::path& filepath);
Expand All @@ -31,7 +31,7 @@ class Alignment {
Alignment();

private:
vector<vector<pair<int, int> > > alignments;
vector<vector<pair<int, int>>> alignments;
};

} // namespace extractor
Expand Down
2 changes: 1 addition & 1 deletion extractor/alignment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AlignmentTest : public Test {
};

TEST_F(AlignmentTest, TestGetLinks) {
vector<pair<int, int> > expected_links = {
vector<pair<int, int>> expected_links = {
make_pair(0, 0), make_pair(1, 1), make_pair(2, 2)
};
EXPECT_EQ(expected_links, alignment->GetLinks(0));
Expand Down
4 changes: 2 additions & 2 deletions extractor/fast_intersector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FastIntersector::FastIntersector(shared_ptr<SuffixArray> suffix_array,
max_rule_span(max_rule_span),
min_gap_size(min_gap_size) {
Index precomputed_collocations = precomputation->GetCollocations();
for (pair<vector<int>, vector<int> > entry: precomputed_collocations) {
for (pair<vector<int>, vector<int>> entry: precomputed_collocations) {
vector<int> phrase = ConvertPhrase(entry.first);
collocations[phrase] = entry.second;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ void FastIntersector::ExtendPhraseLocation(PhraseLocation& location) const {
}

location.num_subpatterns = 1;
location.matchings = make_shared<vector<int> >();
location.matchings = make_shared<vector<int>>();
for (int i = location.sa_low; i < location.sa_high; ++i) {
location.matchings->push_back(suffix_array->GetSuffix(i));
}
Expand Down
2 changes: 1 addition & 1 deletion extractor/fast_intersector.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace std;

namespace extractor {

typedef boost::hash<vector<int> > VectorHash;
typedef boost::hash<vector<int>> VectorHash;
typedef unordered_map<vector<int>, vector<int>, VectorHash> Index;

class Phrase;
Expand Down
2 changes: 1 addition & 1 deletion extractor/matchings_trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct TrieNode {
shared_ptr<TrieNode> suffix_link;
Phrase phrase;
PhraseLocation matchings;
unordered_map<int, shared_ptr<TrieNode> > children;
unordered_map<int, shared_ptr<TrieNode>> children;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion extractor/mocks/mock_alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace extractor {

typedef vector<pair<int, int> > SentenceLinks;
typedef vector<pair<int, int>> SentenceLinks;

class MockAlignment : public Alignment {
public:
Expand Down
12 changes: 6 additions & 6 deletions extractor/mocks/mock_rule_extractor_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MockRuleExtractorHelper : public RuleExtractorHelper {
const vector<int>&, const vector<int>&, int));
MOCK_CONST_METHOD4(CheckTightPhrases, bool(const vector<int>&,
const vector<int>&, const vector<int>&, int));
MOCK_CONST_METHOD1(GetGapOrder, vector<int>(const vector<pair<int, int> >&));
MOCK_CONST_METHOD1(GetGapOrder, vector<int>(const vector<pair<int, int>>&));
MOCK_CONST_METHOD4(GetSourceIndexes, Indexes(const vector<int>&,
const vector<int>&, int, int));

Expand All @@ -36,8 +36,8 @@ class MockRuleExtractorHelper : public RuleExtractorHelper {
return find_fix_point;
}

bool GetGaps(vector<pair<int, int> >& source_gaps,
vector<pair<int, int> >& target_gaps,
bool GetGaps(vector<pair<int, int>>& source_gaps,
vector<pair<int, int>>& target_gaps,
const vector<int>&, const vector<int>&, const vector<int>&,
const vector<int>&, const vector<int>&, const vector<int>&,
int, int, int, int, int, int, int& num_symbols,
Expand All @@ -52,7 +52,7 @@ class MockRuleExtractorHelper : public RuleExtractorHelper {
void SetUp(
int target_phrase_low, int target_phrase_high, int source_back_low,
int source_back_high, bool find_fix_point,
vector<pair<int, int> > source_gaps, vector<pair<int, int> > target_gaps,
vector<pair<int, int>> source_gaps, vector<pair<int, int>> target_gaps,
int num_symbols, bool met_constraints, bool get_gaps) {
this->target_phrase_low = target_phrase_low;
this->target_phrase_high = target_phrase_high;
Expand All @@ -72,8 +72,8 @@ class MockRuleExtractorHelper : public RuleExtractorHelper {
int source_back_low;
int source_back_high;
bool find_fix_point;
vector<pair<int, int> > source_gaps;
vector<pair<int, int> > target_gaps;
vector<pair<int, int>> source_gaps;
vector<pair<int, int>> target_gaps;
int num_symbols;
bool met_constraints;
bool get_gaps;
Expand Down
2 changes: 1 addition & 1 deletion extractor/mocks/mock_target_phrase_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef pair<Phrase, PhraseAlignment> PhraseExtract;
class MockTargetPhraseExtractor : public TargetPhraseExtractor {
public:
MOCK_CONST_METHOD6(ExtractPhrases, vector<PhraseExtract>(
const vector<pair<int, int> > &, const vector<int>&, int, int,
const vector<pair<int, int>>&, const vector<int>&, int, int,
const unordered_map<int, int>&, int));
};

Expand Down
2 changes: 1 addition & 1 deletion extractor/phrase_location.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PhraseLocation::PhraseLocation(int sa_low, int sa_high) :
PhraseLocation::PhraseLocation(const vector<int>& matchings,
int num_subpatterns) :
sa_low(0), sa_high(0),
matchings(make_shared<vector<int> >(matchings)),
matchings(make_shared<vector<int>>(matchings)),
num_subpatterns(num_subpatterns) {}

bool PhraseLocation::IsEmpty() const {
Expand Down
2 changes: 1 addition & 1 deletion extractor/phrase_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct PhraseLocation {
friend bool operator==(const PhraseLocation& a, const PhraseLocation& b);

int sa_low, sa_high;
shared_ptr<vector<int> > matchings;
shared_ptr<vector<int>> matchings;
int num_subpatterns;
};

Expand Down
12 changes: 6 additions & 6 deletions extractor/precomputation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Precomputation::Precomputation(
int max_rule_symbols, int min_gap_size,
int max_frequent_phrase_len, int min_frequency) {
vector<int> data = suffix_array->GetData()->GetData();
vector<vector<int> > frequent_patterns = FindMostFrequentPatterns(
vector<vector<int>> frequent_patterns = FindMostFrequentPatterns(
suffix_array, data, num_frequent_patterns, max_frequent_phrase_len,
min_frequency);

Expand All @@ -34,7 +34,7 @@ Precomputation::Precomputation(
}
}

vector<tuple<int, int, int> > matchings;
vector<tuple<int, int, int>> matchings;
for (size_t i = 0; i < data.size(); ++i) {
// If the sentence is over, add all the discontiguous frequent patterns to
// the index.
Expand Down Expand Up @@ -64,14 +64,14 @@ Precomputation::Precomputation() {}

Precomputation::~Precomputation() {}

vector<vector<int> > Precomputation::FindMostFrequentPatterns(
vector<vector<int>> Precomputation::FindMostFrequentPatterns(
shared_ptr<SuffixArray> suffix_array, const vector<int>& data,
int num_frequent_patterns, int max_frequent_phrase_len, int min_frequency) {
vector<int> lcp = suffix_array->BuildLCPArray();
vector<int> run_start(max_frequent_phrase_len);

// Find all the patterns occurring at least min_frequency times.
priority_queue<pair<int, pair<int, int> > > heap;
priority_queue<pair<int, pair<int, int>>> heap;
for (size_t i = 1; i < lcp.size(); ++i) {
for (int len = lcp[i]; len < max_frequent_phrase_len; ++len) {
int frequency = i - run_start[len];
Expand All @@ -84,7 +84,7 @@ vector<vector<int> > Precomputation::FindMostFrequentPatterns(
}

// Extract the most frequent patterns.
vector<vector<int> > frequent_patterns;
vector<vector<int>> frequent_patterns;
while (frequent_patterns.size() < num_frequent_patterns && !heap.empty()) {
int start = heap.top().second.first;
int len = heap.top().second.second;
Expand All @@ -100,7 +100,7 @@ vector<vector<int> > Precomputation::FindMostFrequentPatterns(
}

void Precomputation::AddCollocations(
const vector<tuple<int, int, int> >& matchings, const vector<int>& data,
const vector<tuple<int, int, int>>& matchings, const vector<int>& data,
int max_rule_span, int min_gap_size, int max_rule_symbols) {
// Select the leftmost subpattern.
for (size_t i = 0; i < matchings.size(); ++i) {
Expand Down
6 changes: 3 additions & 3 deletions extractor/precomputation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace std;

namespace extractor {

typedef boost::hash<vector<int> > VectorHash;
typedef boost::hash<vector<int>> VectorHash;
typedef unordered_map<vector<int>, vector<int>, VectorHash> Index;

class SuffixArray;
Expand Down Expand Up @@ -54,7 +54,7 @@ class Precomputation {

private:
// Finds the most frequent contiguous collocations.
vector<vector<int> > FindMostFrequentPatterns(
vector<vector<int>> FindMostFrequentPatterns(
shared_ptr<SuffixArray> suffix_array, const vector<int>& data,
int num_frequent_patterns, int max_frequent_phrase_len,
int min_frequency);
Expand All @@ -63,7 +63,7 @@ class Precomputation {
// it adds new entries to the index for each discontiguous collocation
// matching the criteria specified in the class description.
void AddCollocations(
const vector<std::tuple<int, int, int> >& matchings, const vector<int>& data,
const vector<std::tuple<int, int, int>>& matchings, const vector<int>& data,
int max_rule_span, int min_gap_size, int max_rule_symbols);

// Adds an occurrence of a binary collocation.
Expand Down
2 changes: 1 addition & 1 deletion extractor/rule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace extractor {
Rule::Rule(const Phrase& source_phrase,
const Phrase& target_phrase,
const vector<double>& scores,
const vector<pair<int, int> >& alignment) :
const vector<pair<int, int>>& alignment) :
source_phrase(source_phrase),
target_phrase(target_phrase),
scores(scores),
Expand Down
4 changes: 2 additions & 2 deletions extractor/rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace extractor {
*/
struct Rule {
Rule(const Phrase& source_phrase, const Phrase& target_phrase,
const vector<double>& scores, const vector<pair<int, int> >& alignment);
const vector<double>& scores, const vector<pair<int, int>>& alignment);

Phrase source_phrase;
Phrase target_phrase;
vector<double> scores;
vector<pair<int, int> > alignment;
vector<pair<int, int>> alignment;
};

} // namespace extractor
Expand Down
8 changes: 4 additions & 4 deletions extractor/rule_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ vector<Rule> RuleExtractor::ExtractRules(const Phrase& phrase,

// Calculate statistics for the (sampled) occurrences of the source phrase.
map<Phrase, double> source_phrase_counter;
map<Phrase, map<Phrase, map<PhraseAlignment, int> > > alignments_counter;
map<Phrase, map<Phrase, map<PhraseAlignment, int>>> alignments_counter;
for (auto i = matchings.begin(); i != matchings.end(); i += num_subpatterns) {
vector<int> matching(i, i + num_subpatterns);
vector<Extract> extracts = ExtractAlignments(phrase, matching);
Expand Down Expand Up @@ -165,7 +165,7 @@ vector<Extract> RuleExtractor::ExtractAlignments(
// Get spans for nonterminal gaps.
bool met_constraints = true;
int num_symbols = phrase.GetNumSymbols();
vector<pair<int, int> > source_gaps, target_gaps;
vector<pair<int, int>> source_gaps, target_gaps;
if (!helper->GetGaps(source_gaps, target_gaps, matching, chunklen, source_low,
source_high, target_low, target_high, source_phrase_low,
source_phrase_high, source_back_low, source_back_high,
Expand Down Expand Up @@ -210,7 +210,7 @@ vector<Extract> RuleExtractor::ExtractAlignments(
void RuleExtractor::AddExtracts(
vector<Extract>& extracts, const Phrase& source_phrase,
const unordered_map<int, int>& source_indexes,
const vector<pair<int, int> >& target_gaps, const vector<int>& target_low,
const vector<pair<int, int>>& target_gaps, const vector<int>& target_low,
int target_phrase_low, int target_phrase_high, int sentence_id) const {
auto target_phrases = target_phrase_extractor->ExtractPhrases(
target_gaps, target_low, target_phrase_low, target_phrase_high,
Expand All @@ -232,7 +232,7 @@ void RuleExtractor::AddNonterminalExtremities(
const vector<int>& chunklen, const Phrase& source_phrase,
int source_back_low, int source_back_high, const vector<int>& source_low,
const vector<int>& source_high, const vector<int>& target_low,
const vector<int>& target_high, vector<pair<int, int> > target_gaps,
const vector<int>& target_high, vector<pair<int, int>> target_gaps,
int sentence_id, int source_sent_start, int starts_with_x, int ends_with_x,
int extend_left, int extend_right) const {
int source_x_low = source_back_low, source_x_high = source_back_high;
Expand Down
6 changes: 3 additions & 3 deletions extractor/rule_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace std;

namespace extractor {

typedef vector<pair<int, int> > PhraseAlignment;
typedef vector<pair<int, int>> PhraseAlignment;

class Alignment;
class DataArray;
Expand Down Expand Up @@ -90,7 +90,7 @@ class RuleExtractor {
void AddExtracts(
vector<Extract>& extracts, const Phrase& source_phrase,
const unordered_map<int, int>& source_indexes,
const vector<pair<int, int> >& target_gaps, const vector<int>& target_low,
const vector<pair<int, int>>& target_gaps, const vector<int>& target_low,
int target_phrase_low, int target_phrase_high, int sentence_id) const;

// Adds a leading and/or trailing nonterminal to the source phrase and
Expand All @@ -101,7 +101,7 @@ class RuleExtractor {
const vector<int>& chunklen, const Phrase& source_phrase,
int source_back_low, int source_back_high, const vector<int>& source_low,
const vector<int>& source_high, const vector<int>& target_low,
const vector<int>& target_high, vector<pair<int, int> > target_gaps,
const vector<int>& target_high, vector<pair<int, int>> target_gaps,
int sentence_id, int source_sent_start, int starts_with_x,
int ends_with_x, int extend_left, int extend_right) const;

Expand Down
6 changes: 3 additions & 3 deletions extractor/rule_extractor_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void RuleExtractorHelper::GetLinksSpans(

target_low = vector<int>(target_sent_len, -1);
target_high = vector<int>(target_sent_len, -1);
vector<pair<int, int> > links = alignment->GetLinks(sentence_id);
vector<pair<int, int>> links = alignment->GetLinks(sentence_id);
for (auto link: links) {
if (source_low[link.first] == -1 || source_low[link.first] > link.second) {
source_low[link.first] = link.second;
Expand Down Expand Up @@ -264,7 +264,7 @@ void RuleExtractorHelper::FindProjection(
}

bool RuleExtractorHelper::GetGaps(
vector<pair<int, int> >& source_gaps, vector<pair<int, int> >& target_gaps,
vector<pair<int, int>>& source_gaps, vector<pair<int, int>>& target_gaps,
const vector<int>& matching, const vector<int>& chunklen,
const vector<int>& source_low, const vector<int>& source_high,
const vector<int>& target_low, const vector<int>& target_high,
Expand Down Expand Up @@ -330,7 +330,7 @@ bool RuleExtractorHelper::GetGaps(
}

vector<int> RuleExtractorHelper::GetGapOrder(
const vector<pair<int, int> >& gaps) const {
const vector<pair<int, int>>& gaps) const {
vector<int> gap_order(gaps.size());
for (size_t i = 0; i < gap_order.size(); ++i) {
for (size_t j = 0; j < i; ++j) {
Expand Down
4 changes: 2 additions & 2 deletions extractor/rule_extractor_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RuleExtractorHelper {

// Find the gap spans for each nonterminal in the source phrase.
virtual bool GetGaps(
vector<pair<int, int> >& source_gaps, vector<pair<int, int> >& target_gaps,
vector<pair<int, int>>& source_gaps, vector<pair<int, int>>& target_gaps,
const vector<int>& matching, const vector<int>& chunklen,
const vector<int>& source_low, const vector<int>& source_high,
const vector<int>& target_low, const vector<int>& target_high,
Expand All @@ -68,7 +68,7 @@ class RuleExtractorHelper {
int& num_symbols, bool& met_constraints) const;

// Get the order of the nonterminals in the target phrase.
virtual vector<int> GetGapOrder(const vector<pair<int, int> >& gaps) const;
virtual vector<int> GetGapOrder(const vector<pair<int, int>>& gaps) const;

// Map each terminal symbol with its position in the source phrase.
virtual unordered_map<int, int> GetSourceIndexes(
Expand Down
Loading

0 comments on commit fc3d47b

Please sign in to comment.