commit 3c5d9936f9c4947f9638f0bb4b6f61edad916880 Author: Tanmai Khanna Date: Sun Jul 21 18:47:54 2019 +0530 Naive Pattern Matching Code (Some Namespace bug still exists) diff --git a/src/anaphora.cc b/src/anaphora.cc index 6f8e577..02d5683 100644 --- a/src/anaphora.cc +++ b/src/anaphora.cc @@ -1,6 +1,7 @@ #include "parse_ref.h" #include "parse_biltrans.h" #include "score.h" +#include "pattern_ref.h" #include #include diff --git a/src/pattern_ref.cc b/src/pattern_ref.cc index e5c3903..8bef1c9 100644 --- a/src/pattern_ref.cc +++ b/src/pattern_ref.cc @@ -3,6 +3,8 @@ #include #include +#include +#include using namespace std; @@ -62,7 +64,7 @@ int check_acceptable_tags(vector input_tags, acceptable_tags check_tags return 0; //if it didn't return 1 then no tag list was fully matched } -check_acceptable_patterns(vector) +//check_acceptable_patterns(vector) deque< vector > add_properties(deque< vector > context, ParseRef ref_file) @@ -76,29 +78,33 @@ deque< vector > add_properties(deque< vector > context, Pa wstring markable_name = it->first; acceptable_patterns patterns_list = it->second; + cout << "Markable: "; + wcout << markable_name; + cout << "\n"; + for(acceptable_patterns::iterator i = patterns_list.begin(); i!=patterns_list.end(); ++i) //go through patterns in the markable { //for each pattern vector current_pattern = *i; + int len_pattern = current_pattern.size(); + + cout << "New Pattern!!!\n"; - for(deque< vector >::iterator j = context.begin(); j!=context.end(); ++j) //go through queue of context to get sentences + for(deque< vector >::iterator m = context.begin(); m!=context.end(); ++m) //go through queue of context to get sentences { - for (vector::iterator j = (*i).begin(); j!=(*i).end(); ++j) //go through sentence to look for the pattern with a sliding window of size = pattern length + for (vector::iterator n = (*m).begin(); n!=(*m).end()-len+1; ++n) //go through sentence to look for the pattern with a sliding window of size = pattern length { - + //i have a current_pattern to compare with a window of pattern size in this sentence + + for(int x = 0; x <= len_pattern; ++x) + { + wcout << (*n+x).wordform; + cout << "\n"; + } } } - } - - } - - /* - for(deque< vector >::iterator i = context.begin(); i!=context.end(); ++i) - { - } - */ return context; } diff --git a/src/pattern_ref.h b/src/pattern_ref.h index a16c01b..47d648e 100644 --- a/src/pattern_ref.h +++ b/src/pattern_ref.h @@ -5,12 +5,30 @@ #include #include +#include using namespace std; +struct unique_LU +{ + unsigned int id; + wstring wordform; + wstring tl_wordform; + vector pos_tags; + vector properties; +}; + +struct antecedent +{ + unique_LU LU; + int score; +}; + int contains(vector tags, wstring tag); int contains_any(vector tags, vector candidates); int check_acceptable_tags(vector input_tags, acceptable_tags check_tags); +deque< vector > add_properties(deque< vector > context, ParseRef ref_file) + #endif \ No newline at end of file diff --git a/src/score.cc b/src/score.cc index e059a2e..0096c22 100644 --- a/src/score.cc +++ b/src/score.cc @@ -27,14 +27,6 @@ void showq(deque < vector > gq) cerr << '\n'; } -void clearq(queue < vector > q) -{ - while(!q.empty()) - { - q.pop(); - } -} - int Scoring::add_word(unsigned int input_id, wstring input_wordform, vector< wstring > input_pos_tags, wstring input_tl_wordform, ParseRef ref_file) { vector temp_prop; diff --git a/src/score.h b/src/score.h index 10cc34f..23b4c77 100644 --- a/src/score.h +++ b/src/score.h @@ -2,6 +2,7 @@ #define _MITKOVSCORE_ #include "parse_ref.h" +#include "pattern_ref.h" #include #include @@ -10,21 +11,6 @@ using namespace std; -struct unique_LU -{ - unsigned int id; - wstring wordform; - wstring tl_wordform; - vector pos_tags; - vector properties; -}; - -struct antecedent -{ - unique_LU LU; - int score; -}; - void showq(deque < vector > gq); class Scoring