1

I pretend to use DictionaryLookup[{"Language", complex_Pattern}] but can not achieve it finally to get it with like three layers ... Specially, I tried Except[c, p] ... but did not arrive to use it because did not produce de wished output

css_ss _s = 
 Select[Select[DictionaryLookup[{"Catalan", ___ ~~ "s" ~~ ___ }], 
   StringMatchQ[#, ___ ~~ "ss" ~~ ___] == False &], 
  StringMatchQ[#, ___ ~~ "s"] == False &]

But the output is what I pretended, the question is: Is there a less layered way to arrive at the same point?

Anxon Pués
  • 907
  • 5
  • 13
  • Maybe try Cases[...,Except[...]] instead of using Select. – Daniel Lichtblau Feb 26 '20 at 18:48
  • 1
    I forgot to say I had tested Cases too, the problem is that using Except I am affraid I do not know how to use and the help does not make it clear, Tried Except[c,___~~"ss"~~___] and also ___Except["ss"]___ well like I told before I do not have strong knowledge on Patterns and Except and about Cases and Select I must recognize that I feel more confortable with Select... finally it worked in this onion-style way – Anxon Pués Feb 26 '20 at 19:06
  • 1
    Mathematica doesn't recognise the syntax css_ss _s =. Is this what you intended? – mikado Feb 26 '20 at 21:01
  • StringMatchQ[#, ___ ~~ "s"] == False & is equivalent to setting pattern in DictionaryLookup to ___~~"s"~~___~~Except["s"] – Wjx Feb 27 '20 at 02:57
  • @mikado - well this naming was not clever I detected the problem after and now use without underlines. – Anxon Pués Feb 27 '20 at 08:59

2 Answers2

1

Here are a few different approaches.

dict = DictionaryLookup[{"Catalan", ___ ~~ "s" ~~ ___}, 140];

DeleteCases[dict, str_ /; StringMatchQ[str,
   Alternatives[___ ~~ "ss" ~~ ___  ,  ___ ~~ "s"]]]

Select[dict, Not@StringMatchQ[#,
    Alternatives[___ ~~ "ss" ~~ ___  ,  ___ ~~ "s"]] &]

Select[dict, (StringFreeQ[#, "ss"] && StringFreeQ[#, "s" ~~ EndOfString]) &]

(*  {"abalisa", "abalisà", "abalisada", "abalisam", "abalisant", "abalisar"}   *)

I could not get Except to work.

LouisB
  • 12,528
  • 1
  • 21
  • 31
0

How about this?

nots = RegularExpression["[^s]"];
DictionaryLookup[{"Catalan", a___ ~~ "s" ~~ b__ /; StringEndsQ[a, nots] && StringStartsQ[b, nots] && StringEndsQ[b, nots]}]

where the substring a has a string length of $ \geq 0 $ and not ends with "s", and at the same time the substring b has a length of $ \geq 1 $ without "s" as its two ends.

And it seems that RegularExpression["[^s]"] can be replaced by Except["s"].