Giter Club home page Giter Club logo

textsearchproblem's Introduction

Text Search with Context

This project creates a simple text search with context.

The input file is tokenized with words being alphanumerics (including apostraphes) and then the remaining is considered punctuation. Searching is case insensitive and returns words around the target to provide context. If this extends to beyond the file, the output will be trimmed by the file bounds.

How This Works

A regex parser goes through and splits each chunk of text that matches the definition of a word and those that don't. These tokens are added to a list to make them easily indexed for retrieval later. On top of this, valid words are added to a HashMap. This map uses the lowercase version of the token as the key and value is an array of all indices where the token was found. This allows us to easily return a list of all locations of a particular word in a given text. During query, the HashMap is used to pull a list of all indices. For each index, a start and end index are calculated. These are mearly the index of the query with the context count on either side. Then a string builder takes the tokens from the token list and appends them together between the two indices we previously calculated. This gives us our word search plus context.

textsearchproblem's People

Contributors

cyanrook avatar

Watchers

James Cloos 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.