diff --git a/CMakeLists.txt b/CMakeLists.txt index 4142ac7ec82767d3a713a60d8504debe91b047a6..7d8e2bd292f3bcb1b406a3c10a39ba1209a84005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(eecs398_search) set(CMAKE_CXX_STANDARD 11) -add_executable(search +add_executable(parser-test main.cpp shared/ProducerConsumerQueue.cpp shared/ProducerConsumerQueue.h @@ -54,6 +54,8 @@ add_executable(ParserEndToEndTest add_executable(URLTEST shared/url.h shared/urlTest.cpp) +add_executable(search-engine search.cpp query/Query.cpp) + find_package(OpenSSL REQUIRED) target_link_libraries(crawl OpenSSL::SSL pthread) diff --git a/makefile b/makefile index bca718edf2aca94398599741c883018a0e1cb486..1a41caa027e2b52af6d0809bf5f1d60a965e31a3 100644 --- a/makefile +++ b/makefile @@ -110,6 +110,19 @@ depend: $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend +#============================================================================= +# Target rules for targets named search-engine + +# Build rule for target. +search-engine: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 search-engine +.PHONY : search-engine + +# fast build rule for target. +search-engine/fast: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/build +.PHONY : search-engine/fast + #============================================================================= # Target rules for targets named URLTEST @@ -136,6 +149,19 @@ ParserEndToEndTest/fast: $(MAKE) -f CMakeFiles/ParserEndToEndTest.dir/build.make CMakeFiles/ParserEndToEndTest.dir/build .PHONY : ParserEndToEndTest/fast +#============================================================================= +# Target rules for targets named StemmerTest + +# Build rule for target. +StemmerTest: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 StemmerTest +.PHONY : StemmerTest + +# fast build rule for target. +StemmerTest/fast: + $(MAKE) -f CMakeFiles/StemmerTest.dir/build.make CMakeFiles/StemmerTest.dir/build +.PHONY : StemmerTest/fast + #============================================================================= # Target rules for targets named TokenizerTest @@ -176,30 +202,17 @@ crawl/fast: .PHONY : crawl/fast #============================================================================= -# Target rules for targets named StemmerTest - -# Build rule for target. -StemmerTest: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 StemmerTest -.PHONY : StemmerTest - -# fast build rule for target. -StemmerTest/fast: - $(MAKE) -f CMakeFiles/StemmerTest.dir/build.make CMakeFiles/StemmerTest.dir/build -.PHONY : StemmerTest/fast - -#============================================================================= -# Target rules for targets named search +# Target rules for targets named parser-test # Build rule for target. -search: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 search -.PHONY : search +parser-test: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 parser-test +.PHONY : parser-test # fast build rule for target. -search/fast: - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/build -.PHONY : search/fast +parser-test/fast: + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/build +.PHONY : parser-test/fast crawler/SocketReader.o: crawler/SocketReader.cpp.o @@ -289,7 +302,7 @@ main.o: main.cpp.o # target to build an object file main.cpp.o: $(MAKE) -f CMakeFiles/crawl.dir/build.make CMakeFiles/crawl.dir/main.cpp.o - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/main.cpp.o + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/main.cpp.o .PHONY : main.cpp.o main.i: main.cpp.i @@ -299,7 +312,7 @@ main.i: main.cpp.i # target to preprocess a source file main.cpp.i: $(MAKE) -f CMakeFiles/crawl.dir/build.make CMakeFiles/crawl.dir/main.cpp.i - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/main.cpp.i + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/main.cpp.i .PHONY : main.cpp.i main.s: main.cpp.s @@ -309,7 +322,7 @@ main.s: main.cpp.s # target to generate assembly for a file main.cpp.s: $(MAKE) -f CMakeFiles/crawl.dir/build.make CMakeFiles/crawl.dir/main.cpp.s - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/main.cpp.s + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/main.cpp.s .PHONY : main.cpp.s parser/Parser.o: parser/Parser.cpp.o @@ -366,6 +379,60 @@ parser/tests/parserTest.cpp.s: $(MAKE) -f CMakeFiles/ParserEndToEndTest.dir/build.make CMakeFiles/ParserEndToEndTest.dir/parser/tests/parserTest.cpp.s .PHONY : parser/tests/parserTest.cpp.s +query/Query.o: query/Query.cpp.o + +.PHONY : query/Query.o + +# target to build an object file +query/Query.cpp.o: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/query/Query.cpp.o +.PHONY : query/Query.cpp.o + +query/Query.i: query/Query.cpp.i + +.PHONY : query/Query.i + +# target to preprocess a source file +query/Query.cpp.i: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/query/Query.cpp.i +.PHONY : query/Query.cpp.i + +query/Query.s: query/Query.cpp.s + +.PHONY : query/Query.s + +# target to generate assembly for a file +query/Query.cpp.s: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/query/Query.cpp.s +.PHONY : query/Query.cpp.s + +search.o: search.cpp.o + +.PHONY : search.o + +# target to build an object file +search.cpp.o: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/search.cpp.o +.PHONY : search.cpp.o + +search.i: search.cpp.i + +.PHONY : search.i + +# target to preprocess a source file +search.cpp.i: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/search.cpp.i +.PHONY : search.cpp.i + +search.s: search.cpp.s + +.PHONY : search.s + +# target to generate assembly for a file +search.cpp.s: + $(MAKE) -f CMakeFiles/search-engine.dir/build.make CMakeFiles/search-engine.dir/search.cpp.s +.PHONY : search.cpp.s + shared/Document.o: shared/Document.cpp.o .PHONY : shared/Document.o @@ -399,7 +466,7 @@ shared/ProducerConsumerQueue.o: shared/ProducerConsumerQueue.cpp.o # target to build an object file shared/ProducerConsumerQueue.cpp.o: - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/shared/ProducerConsumerQueue.cpp.o + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/shared/ProducerConsumerQueue.cpp.o .PHONY : shared/ProducerConsumerQueue.cpp.o shared/ProducerConsumerQueue.i: shared/ProducerConsumerQueue.cpp.i @@ -408,7 +475,7 @@ shared/ProducerConsumerQueue.i: shared/ProducerConsumerQueue.cpp.i # target to preprocess a source file shared/ProducerConsumerQueue.cpp.i: - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/shared/ProducerConsumerQueue.cpp.i + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/shared/ProducerConsumerQueue.cpp.i .PHONY : shared/ProducerConsumerQueue.cpp.i shared/ProducerConsumerQueue.s: shared/ProducerConsumerQueue.cpp.s @@ -417,7 +484,7 @@ shared/ProducerConsumerQueue.s: shared/ProducerConsumerQueue.cpp.s # target to generate assembly for a file shared/ProducerConsumerQueue.cpp.s: - $(MAKE) -f CMakeFiles/search.dir/build.make CMakeFiles/search.dir/shared/ProducerConsumerQueue.cpp.s + $(MAKE) -f CMakeFiles/parser-test.dir/build.make CMakeFiles/parser-test.dir/shared/ProducerConsumerQueue.cpp.s .PHONY : shared/ProducerConsumerQueue.cpp.s shared/urlTest.o: shared/urlTest.cpp.o @@ -589,14 +656,15 @@ help: @echo "... clean" @echo "... depend" @echo "... edit_cache" + @echo "... search-engine" @echo "... URLTEST" @echo "... ParserEndToEndTest" + @echo "... rebuild_cache" + @echo "... StemmerTest" @echo "... TokenizerTest" @echo "... StringProcessingTest" @echo "... crawl" - @echo "... rebuild_cache" - @echo "... StemmerTest" - @echo "... search" + @echo "... parser-test" @echo "... crawler/SocketReader.o" @echo "... crawler/SocketReader.i" @echo "... crawler/SocketReader.s" @@ -615,6 +683,12 @@ help: @echo "... parser/tests/parserTest.o" @echo "... parser/tests/parserTest.i" @echo "... parser/tests/parserTest.s" + @echo "... query/Query.o" + @echo "... query/Query.i" + @echo "... query/Query.s" + @echo "... search.o" + @echo "... search.i" + @echo "... search.s" @echo "... shared/Document.o" @echo "... shared/Document.i" @echo "... shared/Document.s" diff --git a/query/Query.cpp b/query/Query.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f2a62be2ffd18f7e54a2560b317cf09e281d596 --- /dev/null +++ b/query/Query.cpp @@ -0,0 +1,47 @@ +// +// Created by Jake Close on 3/7/18. +// + +#include "Query.h" +#include <iostream> +using namespace std; + +/* + * Searchs the index for the query + * + * + */ + +void QueryParser::search() + { + + if( strcmp(CompleteQuery, "-quit") == 0 ) + { + cout << "Thank you for using C++lue search engine" << endl; + exit(0); + } + else if(strcmp(CompleteQuery, "-help") == 0) + { + cout << "Manual" << endl; + } + + + + return; + + } + + +/* + * + * Prints the top 10 results + * + */ + +void QueryParser::printResults() + { + cout << " Generated XXX results in about XXX seconds " << endl; + + + return; + } \ No newline at end of file diff --git a/query/Query.h b/query/Query.h new file mode 100644 index 0000000000000000000000000000000000000000..0ec50a074949270546848a1f1834dacf227d04ec --- /dev/null +++ b/query/Query.h @@ -0,0 +1,24 @@ +// +// Created by Jake Close on 3/7/18. +// + +#pragma once + +using namespace std; +class QueryParser + { + +public: + QueryParser( const char * query_in) : CompleteQuery( query_in ) + { }; + + void search(); + + void printResults(); + +private: + const char* CompleteQuery; + + }; + + diff --git a/search-engine b/search-engine new file mode 100755 index 0000000000000000000000000000000000000000..2a988337d4ec0110e82d9f37c9b1615797ceb080 Binary files /dev/null and b/search-engine differ diff --git a/search.cpp b/search.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7225e1ab9b2e126c64132c48adeed997ecc6cbd1 --- /dev/null +++ b/search.cpp @@ -0,0 +1,42 @@ +// +// Created by Jake Close on 3/7/18. +// + +#include <iostream> +#include <stdlib.h> +#include <unistd.h> +#include "query/Query.h" + + +using namespace std; + + +int main( int argc, char *argv[] ) + { + + + cout << " --- WELCOME EECS 398 SEARCH ENGINE --- " << endl; + cout << endl; + cout << "What would you like to know? " << endl; + cout << endl; + cout << "type -q to exit or -help for more information" << endl; + string q; + + + + while(true) + { + + while ( getline( cin, q ) && !q.empty( )) + { + QueryParser *query = new QueryParser( q.c_str( )); + query->search( ); + query->printResults( ); + } + + } + + + return 0; + + } \ No newline at end of file