Giter Club home page Giter Club logo

search-engine's Introduction

Search App

Environment

  • Scala 2.12.4
  • sbt 1.0.3
  • Java 8

Run the Test

cd into the project folder and execute sbt test

Project Structure

  • README.md
  • build.sbt
  • src - main - scala - SearchApp.scala
  • src - test - resources
  • src - test - scala - FinderSpec.scala
  • src - test - scala - SearcherSpec.scala

In main, SearchApp.scala contains

  • package object, which is used to define tiny types to represent the data structure used in the application.
  • SearchApp, which is the entry point of the application, and holds files data instantiated during start up in a mutable variable.
  • Searcher, the main class called by SearchApp to perform startup (data initialisation), search (see below) and output result.
  • Finder, the class Searcher used to delegate tasks to traverse file system and load the content of the files.

In test, there are resources folder containing fixtures for testing, and two specs files for testing the two main classes.

Search Algorithm

There are the following parts of the search algorithm

  • Finding all possible combinations of the input value

    • The input value (string) is first being split into a list of strings (determined by space).
    • Then find out all combinations of the words (formed by the words next to each other), such as "The quick brown fox" has 10 possible combinations.
  • Finding matching keywords in the content

    • First find out if there is a match on the first word from the keywords in the content, keywords is a subset (one or more words) from the input keywords.
    • If there is a match, then recursively find the existence of the second word in the content, so on and so forth.
    • If there is no match, either the search will stop and return the matching result, or return empty result.
  • Finding all possible combinations of the input value (keywords) in all the loaded contents

  • Rank the result by using the formula: matchingKeywordsFound / totalNumberOfKeywordsFromInput

  • Produce the final result

search-engine's People

Contributors

mlin6436 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.