Page 1 of 1

get the name of a property given its synonym.

Posted: Sun Jun 27, 2021 7:26 pm
by andresdt
Hello livecoders
I am wondering if there is any way to get the name of a property given one of its synonyms.
Example of "vis" get "visible".
Someone has a different idea than what I came up with.
Since what I came up with is to go to the dictionary and filter the properties and go one by one, see the ones that have a synonym and put all this in a function like the following

Code: Select all

function getSynonyms pName
         change pName
        
             case "rectangle"
                 return "rect"
                 break
            
             case "textdata"
                 return "text"
                 break
            
             case "vis"
                 return "visible"
                 break
            
             default
                 return pName
         end switch
end getSynonyms
a lot of work :oops: :oops:

Re: get the name of a property given its synonym.

Posted: Sun Jun 27, 2021 10:22 pm
by bogs
Not sure I get what your trying to accomplish, or maybe I don't get why heh. Sorry, brain is feeling slow today. :oops:

Re: get the name of a property given its synonym.

Posted: Sun Jun 27, 2021 10:39 pm
by dunbarx
Hi.

Your handler gets the synonyms, but only provided you already know them.

And you might want to say something like:

Code: Select all

case "rectangle"
case "rect"
                 return "rect,rectangle"
                 break
Are asking for a way to get them from the dictionary?

Craig

Re: get the name of a property given its synonym.

Posted: Mon Jun 28, 2021 9:38 am
by stam
dunbarx wrote:
Sun Jun 27, 2021 10:39 pm
Hi.

Your handler gets the synonyms, but only provided you already know them.

And you might want to say something like:

Code: Select all

case "rectangle"
case "rect"
                 return "rect,rectangle"
                 break
Are asking for a way to get them from the dictionary?

Craig
That seems more robust as it can easily take plural forms where they apply...

Re: get the name of a property given its synonym.

Posted: Mon Jun 28, 2021 1:08 pm
by dunbarx
I did not even see the word "change", where a "switch" ought to be.

@andresdt. What was that, anyway?

And the point about plurals is well taken. You could add those to the case statements, I suppose.

But we are all wondering what your purpose is. Perhaps just an exercise in LC?

Craig

Re: get the name of a property given its synonym.

Posted: Tue Jun 29, 2021 12:57 am
by andresdt
Thanks to everyone for your replies
I'm going to try to explain myself better and put them in context a bit. First, my English is not the best, I just write LC jjj. The rest I entrust to the translator :oops: or @prometheus.

For about a year or two, @prometheus and I have been developing a library that allows us to use version controls in LC projects.

One of the many problems we had was.
Suppose we have an object with a constantly changing property, but we are not interested in saving those changes. Example a field where the username is placed. Well, we created a mechanism to tell our library to ignore the text property of that field. Or we can have an object that adjusts to the size of the stack when its dimensions change. In this case, we tell the library to ignore the rect of that object.

The problem here is that I can tell the library to ignore the "rect" of the object, but also tell it to ignore the "rectangle". In the end, the library has to be able to identify that it is the same property and choose a single name, rect in this case.

I don't know if I explain myself better now, in the end I created the function that solves the problem. The downside is that if in a version higher than 9.6.2 (which is the one I'm using), they incorporate another property with synonyms to the engine, this function will have to be refactored.

Re: get the name of a property given its synonym.

Posted: Tue Jun 29, 2021 3:12 am
by dunbarx
I think I see what you are getting at.

But you don't have to deal with that. The nice thing about synonyms is that they are interchangeable. You can mix and match synonyms at will, or, in fact, by accident, and nothing will happen.

I always use one form or the other, never changing. I do this because I just got used to one option. But if I ever accidentally substituted one for the other, I would never know it.

Craig