Skip to main content
added 20 characters in body
Source Link
azerbajdzan
  • 25.1k
  • 2
  • 22
  • 62

It seems like DictionaryLookup was not designed to work with Alternatives of StringExpression in earlier versions and returns only the result for the first alternative.

Instead it works with Alternatives applied to a single characterscharacter.

First line works with "e" | "t" but fourth line DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)] returns result like if it was just DictionaryLookup[(x_ ~~ x_ ~~ y_)].

DictionaryLookup[x_ ~~ "e" | "t"]

DictionaryLookup[x_ ~~ x_ ~~ y_]

DictionaryLookup[x_ ~~ y_ ~~ y_]

DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)]

{"at", "be", "he", "it", "Le", "me", "re", "we", "ye"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

{"add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", "CNN", \
"coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", "goo", \
"ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", "Orr", \
"pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

As a workaround you can use:

DictionaryLookup /@ 
  List @@ ((x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)) // Flatten

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL", "add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", \
"CNN", "coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", \
"goo", "ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", \
"Orr", "pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

It seems like DictionaryLookup was not designed to work with Alternatives of StringExpression and returns only the result for the first alternative.

Instead it works with Alternatives applied to a single characters.

First line works with "e" | "t" but fourth line DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)] returns result like if it was just DictionaryLookup[(x_ ~~ x_ ~~ y_)].

DictionaryLookup[x_ ~~ "e" | "t"]

DictionaryLookup[x_ ~~ x_ ~~ y_]

DictionaryLookup[x_ ~~ y_ ~~ y_]

DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)]

{"at", "be", "he", "it", "Le", "me", "re", "we", "ye"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

{"add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", "CNN", \
"coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", "goo", \
"ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", "Orr", \
"pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

As a workaround you can use:

DictionaryLookup /@ 
  List @@ ((x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)) // Flatten

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL", "add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", \
"CNN", "coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", \
"goo", "ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", \
"Orr", "pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

It seems like DictionaryLookup was not designed to work with Alternatives of StringExpression in earlier versions and returns only the result for the first alternative.

Instead it works with Alternatives applied to a single character.

First line works with "e" | "t" but fourth line DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)] returns result like if it was just DictionaryLookup[(x_ ~~ x_ ~~ y_)].

DictionaryLookup[x_ ~~ "e" | "t"]

DictionaryLookup[x_ ~~ x_ ~~ y_]

DictionaryLookup[x_ ~~ y_ ~~ y_]

DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)]

{"at", "be", "he", "it", "Le", "me", "re", "we", "ye"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

{"add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", "CNN", \
"coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", "goo", \
"ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", "Orr", \
"pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

As a workaround you can use:

DictionaryLookup /@ 
  List @@ ((x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)) // Flatten

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL", "add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", \
"CNN", "coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", \
"goo", "ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", \
"Orr", "pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}
Source Link
azerbajdzan
  • 25.1k
  • 2
  • 22
  • 62

It seems like DictionaryLookup was not designed to work with Alternatives of StringExpression and returns only the result for the first alternative.

Instead it works with Alternatives applied to a single characters.

First line works with "e" | "t" but fourth line DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)] returns result like if it was just DictionaryLookup[(x_ ~~ x_ ~~ y_)].

DictionaryLookup[x_ ~~ "e" | "t"]

DictionaryLookup[x_ ~~ x_ ~~ y_]

DictionaryLookup[x_ ~~ y_ ~~ y_]

DictionaryLookup[(x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)]

{"at", "be", "he", "it", "Le", "me", "re", "we", "ye"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

{"add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", "CNN", \
"coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", "goo", \
"ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", "Orr", \
"pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL"}

As a workaround you can use:

DictionaryLookup /@ 
  List @@ ((x_ ~~ x_ ~~ y_) | (x_ ~~ y_ ~~ y_)) // Flatten

{"aah", "BBC", "DDT", "eek", "eel", "LLB", "ooh", "ppm", "ssh", \
"WWW", "XXL", "add", "all", "Ann", "ass", "baa", "bee", "boo", "brr", \
"CNN", "coo", "Dee", "ebb", "eff", "egg", "ell", "err", "fee", "gee", \
"goo", "ill", "inn", "lee", "Lee", "loo", "moo", "nee", "odd", "off", \
"Orr", "pee", "see", "shh", "tee", "too", "wee", "woo", "WWW", "zoo"}