Code Monkey home page Code Monkey logo

findwordpositions-trie's Introduction

findwordpositions-trie

A program that implements word dictionary with location positions stored from a given text file using trie structure.

It implements something similar to the first half of the following link:

http://www.ardendertat.com/2011/12/20/programming-interview-questions-23-find-word-positions-in-text/

Thanks for the following code snippet for reference at the following site: http://alexcode.tumblr.com/question_9

NOTE: This program stores the first character position of the word within the line number. It does not store the occurrence position of the entire string word.

For instance:

"test frank giordano"

test located at line 1, position 0 frank located at line 1, position 5 etc

whereas all the words positions would be: test located at position 0 and frank located at position 1 and giordano located at position 3

Setup, Installation, and running the application:

1 - Install Java 8

2 - Install Maven 3.6.3 or higher

At project's root directory, perform the following commands:

3 - mvn clean install

4 - java -jar .\target\FindWordPositions.jar

findwordpositions-trie's People

Contributors

frankgiordano avatar

Watchers

James Cloos avatar  avatar

findwordpositions-trie's Issues

Refactor and Fix - Code does not replace each word in file correctly.

After many years I revisited this code and noticed it does not replace words well.

A few issues:

1 - Parsing a line of text compiles a list of word in the line and uses this list to then search the line for each word and store its starting position. This process was finding the word within another larger word and store its position. This is incorrect. It should ignore this case as the program will replace words and not a text string as it would act in this case.

2 - During parsing the line of text and inspecting each word to store its position the code was doing this only for the first instance of the word and did not check further the text until end of line.

3 - Error handling is weak.

4 - String + concatenation usage can cause memory issue and slowness.

5 - Each time a new search request was perform it was rebuilding the dictionary. Avoid this, reuse cache.

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.