Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6207931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:43:11+00:00 2026-05-24T05:43:11+00:00

I have a table of strings (about 100,000) in following format: pattern , string

  • 0

I have a table of strings (about 100,000) in following format:

pattern , string

e.g. –

*l*ph*nt , elephant
c*mp*t*r , computer
s*v* , save
s*nn] , sunny
]*rr] , worry

To simplify, assume a * denotes a vowel, a consonant stands unchanged and ] denotes either a ‘y’ or a ‘w’ (say, for instance, semi-vowels/round-vowels in phonology).

Given a pattern, what is the best way to generate the possible sensible strings? A sensible string is defined as a string having each of its consecutive two-letter substrings, that were not specified in the pattern, inside the data-set.

e.g. –

h*ll* –> hallo, hello, holla …

‘hallo’ is sensible because ‘ha’, ‘al’, ‘lo’ can be seen in the data-set as with the words ‘have’, ‘also’, ‘low’. The two letters ‘ll’ is not considered because it was specified in the pattern.

What are the simple and efficient ways to do this?
Are there any libraries/frameworks for achieving this?

I’ve no specific language in mind but prefer to use java for this program.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:43:11+00:00Added an answer on May 24, 2026 at 5:43 am

    This is particularly well suited to Python itertools, set and re operations:

    import re
    import itertools
    
    VOWELS      = 'aeiou'
    SEMI_VOWELS = 'wy'
    DATASET     = '/usr/share/dict/words'
    SENSIBLES   = set()
    
    def digraphs(word, digraph=r'..'):
        '''
        >>> digraphs('bar')
        set(['ar', 'ba'])
        '''
        base = re.findall(digraph, word)
        base.extend(re.findall(digraph, word[1:]))
        return set(base)
    
    def expand(pattern, wildcard, elements):
        '''
        >>> expand('h?', '?', 'aeiou')
        ['ha', 'he', 'hi', 'ho', 'hu']
        '''
        tokens = re.split(re.escape(wildcard), pattern)
        results = set()
        for perm in itertools.permutations(elements, len(tokens)):
            results.add(''.join([l for p in zip(tokens, perm) for l in p][:-1]))
        return sorted(results)
    
    def enum(pattern):
        not_sensible = digraphs(pattern, r'[^*\]]{2}')
        for p in expand(pattern, '*', VOWELS):
            for q in expand(p, ']', SEMI_VOWELS):
                if (digraphs(q) - not_sensible).issubset(SENSIBLES):
                    print q
    
    ## Init the data-set (may be long...)
    ## you may want to pre-compute this
    ## and adapt it to your data-set.
    for word in open(DATASET, 'r').readlines():
        for digraph in digraphs(word.rstrip()):
            SENSIBLES.add(digraph)
    
    enum('*l*ph*nt')
    enum('s*nn]')
    enum('h*ll*')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have a table in db2 which has the following fields int xyz; string
I have a legacy table with about 100 columns (90% nullable). In those 90
I have a relational database with about 100 tables. Each table has unique, numerical,
I have a table with a TEXT column where the contents is just strings
I have a two-dimensional array (of Strings) which make up my data table (of
I have a table with string values that need to matched individually to a
I have a table with 5 string columns, all can be NULLs. After I
I have this class called Table: class Table { public string Name { get
I have a table containing an url and a string representing its parameters. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.