Skip to content
Snippets Groups Projects
Commit e4cfc14c authored by Jan Trávníček's avatar Jan Trávníček
Browse files

allow translating begin index of occ to end index

parent a3528fba
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
#include <arbology/exact/ExactPatternMatchingAutomaton.h>
#include <arbology/exact/ExactSubtreeAutomaton.h>
#include <arbology/exact/ExactTreePatternAutomaton.h>
#include <arbology/transform/BeginToEndIndex.h>
#include <chrono>
 
int main ( int argc, char * argv[] ) {
......@@ -49,6 +50,9 @@ int main ( int argc, char * argv[] ) {
TCLAP::MultiArg < std::string > pattern ( "p", "pattern", "Pattern tree from file", false, "file" );
cmd.add ( pattern );
 
TCLAP::SwitchArg ends ( "e", "ends", "Return occurrences as end indexes when applicable", false );
cmd.add ( ends );
TCLAP::SwitchArg measure ( "m", "measure", "Measure times", false );
cmd.add ( measure );
 
......@@ -121,6 +125,8 @@ int main ( int argc, char * argv[] ) {
std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
std::set < unsigned > res = arbology::exact::ExactSubtreeMatch::match ( subject, pattern );
if( ends.isSet ( ) )
res = arbology::transform::BeginToEndIndex::transform(subject, res);
 
std::chrono::measurements::end ( );
std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
......@@ -134,6 +140,8 @@ int main ( int argc, char * argv[] ) {
std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
std::set < unsigned > res = arbology::exact::ExactPatternMatch::match ( subject, pattern );
if( ends.isSet ( ) )
res = arbology::transform::BeginToEndIndex::transform(subject, res);
 
std::chrono::measurements::end ( );
std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
......@@ -147,6 +155,8 @@ int main ( int argc, char * argv[] ) {
std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
std::set < unsigned > res = arbology::exact::BoyerMooreHorspool::match ( subject, pattern );
if( ends.isSet ( ) )
res = arbology::transform::BeginToEndIndex::transform(subject, res);
 
std::chrono::measurements::end ( );
std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
......@@ -160,6 +170,8 @@ int main ( int argc, char * argv[] ) {
std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
std::set < unsigned > res = arbology::exact::KnuthMorrisPratt::match ( subject, pattern );
if( ends.isSet ( ) )
res = arbology::transform::BeginToEndIndex::transform(subject, res);
 
std::chrono::measurements::end ( );
std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
......
......@@ -23,7 +23,7 @@ std::set < unsigned > BeginToEndIndex::transform ( const tree::Tree & subject, c
}
 
std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedBarTree & subject, const std::set < unsigned > & indexes ) {
std::vector < int > subjectSubtreeJumpTable = SubtreeJumpTable::compute ( subject );
std::vector < int > subjectSubtreeJumpTable = exact::SubtreeJumpTable::compute ( subject );
std::set < unsigned > res;
 
for ( unsigned index : indexes )
......@@ -35,7 +35,7 @@ std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedBarTr
auto BeginToEndIndexPrefixRankedBarTreePrefixRankedBarTree = BeginToEndIndex::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedBarTree > ( BeginToEndIndex::getInstance ( ), BeginToEndIndex::transform );
 
std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedTree & subject, const std::set < unsigned > & indexes ) {
std::vector < int > subjectSubtreeJumpTable = SubtreeJumpTable::compute ( subject );
std::vector < int > subjectSubtreeJumpTable = exact::SubtreeJumpTable::compute ( subject );
std::set < unsigned > res;
 
for ( unsigned index : indexes )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment