-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
3,878 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
bin_PROGRAMS = compile run_extractor | ||
|
||
noinst_PROGRAMS = \ | ||
binary_search_merger_test \ | ||
data_array_test \ | ||
linear_merger_test \ | ||
matching_comparator_test \ | ||
matching_test \ | ||
matchings_finder_test \ | ||
phrase_test \ | ||
precomputation_test \ | ||
suffix_array_test \ | ||
veb_test | ||
|
||
TESTS = precomputation_test | ||
#TESTS = binary_search_merger_test \ | ||
# data_array_test \ | ||
# linear_merger_test \ | ||
# matching_comparator_test \ | ||
# matching_test \ | ||
# phrase_test \ | ||
# suffix_array_test \ | ||
# veb_test | ||
|
||
binary_search_merger_test_SOURCES = binary_search_merger_test.cc | ||
binary_search_merger_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
data_array_test_SOURCES = data_array_test.cc | ||
data_array_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) libextractor.a | ||
linear_merger_test_SOURCES = linear_merger_test.cc | ||
linear_merger_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
matching_comparator_test_SOURCES = matching_comparator_test.cc | ||
matching_comparator_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) libextractor.a | ||
matching_test_SOURCES = matching_test.cc | ||
matching_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) libextractor.a | ||
matchings_finder_test_SOURCES = matchings_finder_test.cc | ||
matchings_finder_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
phrase_test_SOURCES = phrase_test.cc | ||
phrase_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
precomputation_test_SOURCES = precomputation_test.cc | ||
precomputation_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
suffix_array_test_SOURCES = suffix_array_test.cc | ||
suffix_array_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(GMOCK_LDFLAGS) $(GMOCK_LIBS) libextractor.a | ||
veb_test_SOURCES = veb_test.cc | ||
veb_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) libextractor.a | ||
|
||
noinst_LIBRARIES = libextractor.a libcompile.a | ||
|
||
compile_SOURCES = compile.cc | ||
compile_LDADD = libcompile.a | ||
run_extractor_SOURCES = run_extractor.cc | ||
run_extractor_LDADD = libextractor.a | ||
|
||
libcompile_a_SOURCES = \ | ||
alignment.cc \ | ||
data_array.cc \ | ||
phrase_location.cc \ | ||
precomputation.cc \ | ||
suffix_array.cc \ | ||
translation_table.cc | ||
|
||
libextractor_a_SOURCES = \ | ||
alignment.cc \ | ||
binary_search_merger.cc \ | ||
data_array.cc \ | ||
grammar_extractor.cc \ | ||
matching.cc \ | ||
matching_comparator.cc \ | ||
matchings_finder.cc \ | ||
intersector.cc \ | ||
linear_merger.cc \ | ||
matchings_trie.cc \ | ||
phrase.cc \ | ||
phrase_builder.cc \ | ||
phrase_location.cc \ | ||
precomputation.cc \ | ||
rule_extractor.cc \ | ||
rule_factory.cc \ | ||
suffix_array.cc \ | ||
translation_table.cc \ | ||
veb.cc \ | ||
veb_bitset.cc \ | ||
veb_tree.cc \ | ||
vocabulary.cc | ||
|
||
AM_CPPFLAGS = -W -Wall -Wno-sign-compare -std=c++0x $(GTEST_CPPFLAGS) $(GMOCK_CPPFLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "alignment.h" | ||
|
||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <vector> | ||
|
||
#include <boost/algorithm/string.hpp> | ||
#include <boost/filesystem.hpp> | ||
|
||
namespace fs = boost::filesystem; | ||
using namespace std; | ||
|
||
Alignment::Alignment(const string& filename) { | ||
ifstream infile(filename.c_str()); | ||
string line; | ||
while (getline(infile, line)) { | ||
vector<string> items; | ||
boost::split(items, line, boost::is_any_of(" -")); | ||
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]))); | ||
} | ||
alignments.push_back(alignment); | ||
} | ||
// Note: shrink_to_fit does nothing for vector<vector<string> > on g++ 4.6.3, | ||
// but let's hope that the bug will be fixed in a newer version. | ||
alignments.shrink_to_fit(); | ||
} | ||
|
||
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) { | ||
size = alignment.size(); | ||
fwrite(&size, sizeof(int), 1, file); | ||
fwrite(alignment.data(), sizeof(pair<int, int>), size, file); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef _ALIGNMENT_H_ | ||
#define _ALIGNMENT_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include <boost/filesystem.hpp> | ||
|
||
namespace fs = boost::filesystem; | ||
using namespace std; | ||
|
||
class Alignment { | ||
public: | ||
Alignment(const string& filename); | ||
|
||
vector<pair<int, int> > GetLinks(int sentence_index) const; | ||
|
||
void WriteBinary(const fs::path& filepath); | ||
|
||
private: | ||
vector<vector<pair<int, int> > > alignments; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.