JavaAlgorithms
Elementary and no so elementary Java algorithms
stringAlgorithms.SentenceRecognize Class Reference

List of all members.

Public Member Functions

 SentenceRecognize ()
boolean isSentence (String sentence)

Protected Member Functions

boolean isWord (String word)

Static Protected Attributes

static final String dictionary []

Detailed Description

SentenceRecognize

This little algorithm is yet another white board interview problem that I ran into at a company named MapR. I can't think of any application for this algorithm. Hopefully it will help you, dear reader.

The MapR recruiter contacted me and got me to interview with MapR. As is the case with so many companies these days, after I took the time to interview with MapR I never heard from them (or the recruiter) again.

Sep 28, 2013

Author:
Ian Kaplan, iank@bearcave.com

Definition at line 32 of file SentenceRecognize.java.


Constructor & Destructor Documentation

stringAlgorithms.SentenceRecognize.SentenceRecognize ( )

Definition at line 39 of file SentenceRecognize.java.


Member Function Documentation

boolean stringAlgorithms.SentenceRecognize.isSentence ( String  sentence)

Determine if a sentence, composed of a separator free set of words, is a valid sentence (e.g., entirely composed of words from the dictionary). Some examples are listed below (not all words are valid english words):

  • dropedapple : dropped apple
  • dropedith : drop edith
  • arearmarea : are arm area
  • aappledoped : a apple doped
  • hedropedtheball : he dropped the ball
  • areanaitcharm : areana it charm
Parameters:
sentencethe "sentence" to be tested
Returns:
true if the separator free sentence is composed of words found in the dictionary, false otherwise.

Definition at line 91 of file SentenceRecognize.java.

boolean stringAlgorithms.SentenceRecognize.isWord ( String  word) [protected]

Search for a word in the dictionary

Parameters:
wordthe word being searched for
Returns:
true if the word is found, false otherwise

Definition at line 46 of file SentenceRecognize.java.


Member Data Documentation

final String stringAlgorithms.SentenceRecognize.dictionary[] [static, protected]
Initial value:
 {"a", "an", "at", "attach", "attached", "he", "apple", "are", "area", 
                                                  "arean", "areana", "arm", "charm", "lever", "clever", "drop", 
                                                  "droped", "dope", "doped", "it", "the", "edith", "ball"}

Definition at line 35 of file SentenceRecognize.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables