Author Topic: Alphabet character string only  (Read 13011 times)

0 Members and 2 Guests are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Alphabet character string only
« Reply #45 on: April 11, 2018, 03:31:54 PM »
Thinking off topic :

Just thinking about alphabetic punctuation ... just 'cause ...

The hyphen is interesting ; could be considered ( or used as ) a minus sign and exponent.
We would need to build in some interesting test cases for hyphenated characters.

Ditto Full-Stop and the decimal marker.

... and that's without the usage of special characters in some languages ...

On the kdub track: Contextual rabbit-hole! ...A few years ago I had a lot of fun writing a few parsers, and compilers because underneath it all, it is just linguistics. It's so much fun--and difficult--trying to understand context even from simple-straight-forward languages like programming languages (where "punctuation" and "grammar" don't necessarily apply). For example, take a look at the current code you have in front of you and just try to map out how you'd determine simple things like what is a built-in function vs variable; a simple task at first because you can build a symbol table for built-in's and use declarations for recognizing variable names--and build a cross-reference list--but the whole operation gets more complicated when you get to actual assignments and calls. Not to mention confusing because you have to design, create and traverse symtabs and abstract syntax tree's about a thousand times a second before you get to any sort of "decision part".

You don't have "assignments" in an actual language (e.g. English) but you do have metaphors and similes. ...Ugh!
« Last Edit: April 11, 2018, 03:35:19 PM by John Kaul (Se7en) »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Alphabet character string only
« Reply #46 on: April 11, 2018, 06:04:02 PM »
Now I find myself craving to work on this stuff again.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #47 on: April 12, 2018, 04:48:53 AM »
Just for fun:
Code: [Select]
...
_$ (DependsOnYourAlphabet "This is not my alphabet" (MyCyrillicAlphabet)) >> nil
_$ (DependsOnYourAlphabet "Това е моята азбука" (MyCyrillicAlphabet)) >> T
I'm not an expert so I do not make judgments about it, but I think it's better to exclude all non-alphabetic characters than to include numerical ones.
Note: " !\"#$%&()*+,/123456789:;<=>?@[\\]^_`{|}~" < need to add other not Alpha
Edit: It's still great work to include Unicode characters.    >>> not true...
Edit2: seem ok for Unicode.
This is the only word I found that is written with the accent in English (American): "Yaoundé"
Code: [Select]
(foo "Yaoundé") => T
(DependsOnYourAlphabet "Yaoundé" "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz -_.'") => nil

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Alphabet character string only
« Reply #48 on: April 12, 2018, 05:43:53 AM »
It returned nil because you didn't included that character as a member of your alphabet,
I'm unable to test it in VLIDE, since it translates it to "e", but would this work:
Code: [Select]
(DependsOnYourAlphabet "Yaoundé" "éAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz -_.'")
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Alphabet character string only
« Reply #49 on: April 12, 2018, 10:13:36 AM »
Did not read this whole thread, but this is what first came to my mind:
Code - Auto/Visual Lisp: [Select]
  1. (defun nonumbers (s) (vl-every '(lambda (x) (not (<= 47 x 56))) (vl-string->list s)))
  2. (setq l '("abc"       "a"         "Marc'Antonio"          "Marco-Antonio"         "MarcAntonio."
  3.           "a.b"       "."         "abc "      "1.2"       "a b"       ""          "0"
  4.           "0.0"       "a0.0"      "-1"        ".1"        "Yaoundé"
  5.          )
  6. )
  7. (mapcar '(lambda (x) (list x (nonumbers x))) l)
  8. ;;(("abc" T) ("a" T) ("Marc'Antonio" T) ("Marco-Antonio" T) ("MarcAntonio." T) ("a.b" T) ("." T) ("abc " T) ("1.2" nil) ("a b" T) ("" T) ("0" nil) ("0.0" nil) ("a0.0" nil) ("-1" nil) (".1" nil) ("Yaoundé" T))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #50 on: April 12, 2018, 11:07:29 AM »
Did not read this whole thread, but this is what first came to my mind:
Code - Auto/Visual Lisp: [Select]
  1. (defun nonumbers (s) (vl-every '(lambda (x) (not (<= 47 x 56))) (vl-string->list s)))
  2. (setq l   '("abc"         "a"     "Marc'Antonio"     "Marco-Antonio"     "MarcAntonio."
  3.      "a.b"         "."     "abc "      "1.2"     "a b"         ""     "0"
  4.      "0.0"         "a0.0"     "-1"         ".1"     "Yaoundé"
  5.     )
  6. )
  7. (mapcar '(lambda (x) (list x (nonumbers x))) l)
  8. ;;(("abc" T) ("a" T) ("Marc'Antonio" T) ("Marco-Antonio" T) ("MarcAntonio." T) ("a.b" T) ("." T) ("abc " T) ("1.2" nil) ("a b" T) ("" T) ("0" nil) ("0.0" nil) ("a0.0" nil) ("-1" nil) (".1" nil) ("Yaoundé" T))
Is similar:
Code: [Select]
;gile
(defun AlphaOnly (s)
  (vl-every
    '(lambda (x) (< 64 x 91))
    (vl-string->list (strcase s))
  )
)
("abc " T) ("a b" T) ("" T)
Null strings or spaces appear not to be allowed.  :)


Edit: the real question is not "nonumbers" but "isalpha" ...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Alphabet character string only
« Reply #51 on: April 12, 2018, 12:53:11 PM »
Null strings or spaces appear not to be allowed.  :)

That was answered here.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #53 on: April 12, 2018, 01:14:37 PM »
Just for fun:
Code: [Select]
(defun DependsOnYourAlphabet ( Str MyAlphabet )
  (
    (lambda ( f s a )
      (if (/= s "")
        (f s a)
      )
    )
    (lambda ( s a )
      (or (= s "")
        (and
          (vl-string-search (substr s 1 1) a)
          (f (substr s 2) a)
        )
      )
    )
    Str MyAlphabet
  )
); defun DependsOnYourAlphabet
...
_$ (DependsOnYourAlphabet "Това е моята азбука" (MyCyrillicAlphabet)) >> T
Comando: (vl-string-search (substr "Това е моята азбука" 1 1) "е Това е моята азбука")
0

Comando: (substr "Това е моята азбука" 1 1)
"\\"

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Alphabet character string only
« Reply #54 on: April 12, 2018, 03:20:42 PM »
Comando: (vl-string-search (substr "Това е моята азбука" 1 1) "е Това е моята азбука")
0

Comando: (substr "Това е моята азбука" 1 1)
"\\"

Everythings fine on my end:

Code: [Select]
_$  (vl-string-search (substr "Това е моята азбука" 1 1) "е Това е моята азбука")
2
_$ (substr "Това е моята азбука" 1 1)
"Т"

Maybe you have the same issue as I'm having with the Spanish alphabet - VLIDE doesn't recognise these characters.


Null strings or spaces appear not to be allowed.  :)

That was answered here.

I'm wondering how this doesn't have billions previews, Michael. :)
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #55 on: April 12, 2018, 03:30:39 PM »
Comando: (vl-string-search (substr "Това е моята азбука" 1 1) "е Това е моята азбука")
0

Comando: (substr "Това е моята азбука" 1 1)
"\\"

Everythings fine on my end:

Code: [Select]
_$  (vl-string-search (substr "Това е моята азбука" 1 1) "е Това е моята азбука")
2
_$ (substr "Това е моята азбука" 1 1)
"Т"

Maybe you have the same issue as I'm having with the Spanish alphabet - VLIDE doesn't recognise these characters.
Ok, thanks for test.  :)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #56 on: April 12, 2018, 05:05:36 PM »
@Grrr1337: Sorry if I repeat the question, do you think it's better to exclude numeric or symbolic characters rather than to include alphabetic characters?
Code: [Select]
; by Grrrr1337 (modified see: < not)
; (setq NotAlpha " !\"#$%&()*+,/0123456789:;<=>?@[\\]^_`{|}~")
; (String_AlphaP "Yaoundé" NotAlpha)
(defun String_AlphaP ( Str NotAlpha )
  (
    (lambda ( f s a )
      (if (/= s "")
        (f s a)
      )
    )
    (lambda ( s a )
      (or (= s "")
        (and
          (not (vl-string-search (substr s 1 1) a)); < not
          (f (substr s 2) a)
        )
      )
    )
    Str NotAlpha
  )
)
:-)

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: Alphabet character string only
« Reply #57 on: April 12, 2018, 05:23:04 PM »
Maybe you have the same issue as I'm having with the Spanish alphabet - VLIDE doesn't recognise these characters.
VLIDE (unlike Autocad Text Window) does not support Unicode, so it recognizes only those characters that belong to your local code page.
for you (and me) it's cyrillic windows-1251 and "Това е моята азбука" is OK because all characters fit into our 8-bit code page

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Alphabet character string only
« Reply #58 on: April 12, 2018, 05:24:34 PM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Alphabet character string only
« Reply #59 on: April 13, 2018, 02:36:01 AM »
:) :tickedoff: 8)

uh huh
Sorry if I do not comment but I would not misunderstand the "Canadian" irony... it happens that in a different language the same thing has a different meaning.
What I have just written, in fact, can be interpreted in various ways... (Google translation).
Grazie per il tempo che dedichi a questo newsgroup.  :-)

Since I'm here I made another variant:
Code: [Select]
; (setq NotAlpha " !\"#$%&()*+,/0123456789:;<=>?@[\\]^_`{|}~")
; (ALE_String_AlphaP "Yaoundé" NotAlpha)
;
(defun ALE_String_AlphaP (s n / f)
  (defun f (s n)
    (cond
      ( (= s "") )
      ( (and (not (vl-string-search (substr s 1 1) n)) (f (substr s 2) n)) )
    )
  )
  (cond ( (= s "") nil )  ( (f s n) ))
)
;variante con IF
(defun ALE_String_AlphaP (s n / f)
  (defun f (s n)
    (if (/= s "")
      (and
        (not (vl-string-search (substr s 1 1) n))
        (f (substr s 2) n)
      )
      T
    )
  )
  (and (/= s "") (f s n))
)