Class WordDictionary

java.lang.Object
org.drip.service.common.WordDictionary

public class WordDictionary
extends java.lang.Object
WordDictionary is a data structure that supports the following two operations: addWord and search. Search can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.



Author:
Lakshmi Krishnamurthy
  • Constructor Summary

    Constructors
    Constructor Description
    WordDictionary()
    WordDictionary Constructor
  • Method Summary

    Modifier and Type Method Description
    boolean addWord​(java.lang.String word)
    Add a Word to the Set
    static void main​(java.lang.String[] argumentArray)
    Entry Point
    boolean search​(java.lang.String word)
    Return if the word is in the data structure.
    java.util.List<java.lang.String> wordBreakSentenceList​(java.lang.String s)
    Given a non-empty string and a dictionary containing a list of non-empty words, add spaces in the string to construct a sentence where each word is a valid dictionary word.
    java.util.Set<java.lang.String> wordSet()
    Retrieve the Set of Words

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WordDictionary

      public WordDictionary()
      WordDictionary Constructor
  • Method Details

    • wordSet

      public java.util.Set<java.lang.String> wordSet()
      Retrieve the Set of Words
      Returns:
      The Set of Words
    • addWord

      public boolean addWord​(java.lang.String word)
      Add a Word to the Set
      Parameters:
      word - The Word
      Returns:
      TRUE - The Word successfully added
    • search

      public boolean search​(java.lang.String word)
      Return if the word is in the data structure. A word could contain the dot character '.' to represent any one letter.
      Parameters:
      word - The Word
      Returns:
      TRUE - The Word Exists
    • wordBreakSentenceList

      public java.util.List<java.lang.String> wordBreakSentenceList​(java.lang.String s)
      Given a non-empty string and a dictionary containing a list of non-empty words, add spaces in the string to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. Note: The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate words.
      Parameters:
      s - Input String
      Returns:
      List of all Possible Sentences
    • main

      public static final void main​(java.lang.String[] argumentArray)
      Entry Point
      Parameters:
      argumentArray - Argument Array