diff --git a/concordia-console/concordia-console.cpp b/concordia-console/concordia-console.cpp index 932484f..4240c3d 100644 --- a/concordia-console/concordia-console.cpp +++ b/concordia-console/concordia-console.cpp @@ -9,7 +9,7 @@ #include "concordia/common/utils.hpp" #include "build/libdivsufsort/include/divsufsort.h" -#define READ_BUFFER_LENGTH 1000 +#define READ_BUFFER_LENGTH 10000 namespace po = boost::program_options; @@ -22,9 +22,9 @@ int main(int argc, char** argv) { "Concordia configuration file (required)") ("generate-index,g", "Generate suffix array based index out of " "added sentences") - ("load-index,l", "Load the generated index for searching") ("simple-search,s", boost::program_options::value(), "Pattern to be searched in the index") + ("silent,n", "While searching, do not output search results") ("read-file,r", boost::program_options::value(), "File to be read and added to index"); @@ -61,7 +61,7 @@ int main(int argc, char** argv) { boost::posix_time::time_duration msdiff = time_end - time_start; std::cout << "\tIndex generated in: " << msdiff.total_milliseconds() << "ms." << std::endl; - } else if (cli.count("load-index")) { + } else if (cli.count("simple-search")) { std::cout << "\tLoading index..." << std::endl; boost::posix_time::ptime time_start = boost::posix_time::microsec_clock::local_time(); @@ -71,10 +71,24 @@ int main(int argc, char** argv) { boost::posix_time::time_duration msdiff = time_end - time_start; std::cout << "\tIndex loaded in: " << msdiff.total_milliseconds() << "ms." << std::endl; - } else if (cli.count("simple-search")) { + std::string pattern = cli["simple-search"].as(); std::cout << "\tSearching for pattern: \"" << pattern << "\"" << std::endl; + time_start = boost::posix_time::microsec_clock::local_time(); + vector result = concordia.simpleSearch(pattern); + time_end = boost::posix_time::microsec_clock::local_time(); + msdiff = time_end - time_start; + std::cout << "\tFound: " << result.size() << " matches. " + << "Search took: " << + msdiff.total_milliseconds() << "ms." << std::endl; + if (!cli.count("silent")) { + for (vector::iterator it = result.begin(); + it != result.end(); ++it) { + std::cout << "\t\tfound match on word number: " << *it + << std::endl; + } + } } else if (cli.count("read-file")) { std::string filePath = cli["read-file"].as(); std::cout << "\tReading sentences from file: " << filePath << diff --git a/concordia-runner-large.sh b/concordia-runner-large.sh new file mode 100755 index 0000000..72a5284 --- /dev/null +++ b/concordia-runner-large.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +echo "Running Concordia" + +rm prod/resources/temp/* +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -r prod/resources/text-files/large.txt +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -g +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -s "drawn from his own" -n +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -s "it is" -n diff --git a/concordia-runner.sh b/concordia-runner.sh index 9c81623..e4f93bb 100755 --- a/concordia-runner.sh +++ b/concordia-runner.sh @@ -5,6 +5,5 @@ echo "Running Concordia" rm prod/resources/temp/* ./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -r prod/resources/text-files/medium.txt ./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -g -./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -l -#./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -s "Ala ma chyba kota" - +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -s "drawn from his own" +./build/concordia-console/concordia-console -c prod/resources/concordia-config/concordia.cfg -s "it is" -n diff --git a/prod/resources/text-files/large.txt.REMOVED.git-id b/prod/resources/text-files/large.txt.REMOVED.git-id new file mode 100644 index 0000000..ac1d82d --- /dev/null +++ b/prod/resources/text-files/large.txt.REMOVED.git-id @@ -0,0 +1 @@ +8f5abeba4f43e795e84bbdef654dd76d92b4a448 \ No newline at end of file