diff --git a/aarbology2/src/aarbology.cpp b/aarbology2/src/aarbology.cpp index f30596a08256b3701568ed4c7d0a5dca33c04ddd..b46c3ae537f12bac270b2ff8fe4ba4c32fd567b1 100644 --- a/aarbology2/src/aarbology.cpp +++ b/aarbology2/src/aarbology.cpp @@ -60,6 +60,9 @@ int main ( int argc, char * argv[] ) { TCLAP::ValueArg < std::string > nonlinearVariablesInput ( "n", "nonlinear_variables", "Set of nonlinear variables to be used in algorithms needing it", false, "-", "file" ); cmd.add ( nonlinearVariablesInput ); + TCLAP::ValueArg < std::string > variablesBarInput ( "b", "variables_bar", "Variables bar symbol of subtree wildcard and nonlinear variables", false, "-", "file" ); + cmd.add ( variablesBarInput ); + TCLAP::SwitchArg ends ( "e", "ends", "Return occurrences as end indexes when applicable", false ); cmd.add ( ends ); @@ -158,6 +161,26 @@ int main ( int argc, char * argv[] ) { parser.parse ( )->run ( environment ); } + bool isBarNotation = false; + + if ( algorithm.getValue ( ) == "exactTreePatternAutomaton" + || algorithm.getValue ( ) == "exactNonlinearTreePatternAutomaton" ) { + std::string inputType = environment.getVariable ( "subject" )->getReturnType ( ); + isBarNotation = inputType.find ( "Bar" ) != std::string::npos; + + if ( isBarNotation ) { + std::string input; + if ( ! variablesBarInput.isSet ( ) ) + input = "-"; + else + input = variablesBarInput.getValue ( ); + + environment.setBinding ( "inputVariablesBar", input ); + cli::Parser parser ( cli::Lexer ( "execute <:ranked_symbol #inputVariablesBar > $variablesBar" ) ); + parser.parse ( )->run ( environment ); + } + } + measurements::end ( ); measurements::start ( "Algorithm", measurements::Type::MAIN ); @@ -181,9 +204,15 @@ int main ( int argc, char * argv[] ) { } else if ( algorithm.getValue ( ) == "exactSubtreeAutomaton" ) { cliCommand = "execute arbology::exact::ExactSubtreeAutomaton $subject > $output"; } else if ( algorithm.getValue ( ) == "exactTreePatternAutomaton" ) { - cliCommand = "execute arbology::exact::ExactTreePatternAutomaton $subject $subtreeWildcard > $output"; + if ( isBarNotation ) + cliCommand = "execute arbology::exact::ExactTreePatternAutomaton $subject $subtreeWildcard $variablesBar > $output"; + else + cliCommand = "execute arbology::exact::ExactTreePatternAutomaton $subject $subtreeWildcard > $output"; } else if ( algorithm.getValue ( ) == "exactNonlinearTreePatternAutomaton" ) { - cliCommand = "execute arbology::exact::ExactNonlinearTreePatternAutomaton $subject $subtreeWildcard $nonlinearVariables > $output"; + if ( isBarNotation ) + cliCommand = "execute arbology::exact::ExactNonlinearTreePatternAutomaton $subject $subtreeWildcard $nonlinearVariables $variablesBar > $output"; + else + cliCommand = "execute arbology::exact::ExactNonlinearTreePatternAutomaton $subject $subtreeWildcard $nonlinearVariables > $output"; } else if ( algorithm.getValue ( ) == "exactSubtreeRepeatsNaive" ) { cliCommand = "execute tree::properties::ExactSubtreeRepeatsNaive $subject > $output"; } else if ( algorithm.getValue ( ) == "normalizeTreeLabels" ) { diff --git a/tests.aarbology.sh b/tests.aarbology.sh index 92d264058a5dbedddfc856c66d422e9bbf983dfb..e252e203c39068fc7c6f1312b46340c501b39408 100755 --- a/tests.aarbology.sh +++ b/tests.aarbology.sh @@ -428,9 +428,11 @@ runTestPatternEnds "Exact Pattern Matching Automaton (PrefixRanked)" "./aarbolog RAND_SIZE_SUBJECT=120 runTestPatternEnds "Exact Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -o get -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" + RAND_SIZE_SUBJECT=80 runTestNonlinearPatternEnds "Exact Nonlinear Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactNonlinearTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -o get -i \"\$PATTERN_FILE\" ) -n <( ./aaccess2 --tree nonlinear_variables -o get -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedNonlinearPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) -f <(echo '<Set />') | ./aql2 -q 'execute < :pair_set #stdin | dataAccess::PairSetFirst - >#stdout' | ./astat2 -p size" +runTestNonlinearPattern "Exact Nonlinear Tree Pattern Automaton (PrefixRankedBar)" "./aarbology2 -a exactNonlinearTreePatternAutomaton -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -o get -i \"\$PATTERN_FILE\" ) -n <( ./aaccess2 --tree nonlinear_variables -o get -i \"\$PATTERN_FILE\" ) -b <( ./aaccess2 --tree variables_bar -o get -i <(./acast2 -t PrefixRankedBarNonlinearPattern -i \"\$PATTERN_FILE\" ) ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedBarNonlinearPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) -f <(echo '<Set />') | ./aql2 -q 'execute < :pair_set #stdin | dataAccess::PairSetFirst - >#stdout' | ./astat2 -p size" RAND_SIZE_SUBJECT=1000 runTestSubtree "Exact Boyer Moore Horspool (Subtree PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarTree -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -c <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size"