||. But I don't think we can derive that big is a synonym of huge from such
an index.

Well, you can if you invert it:

0. Have an arbitrary "meaning" counter set to 0.
1. The first pair are new, so you increment your meaning counter and create
set #1 containing the first pair.
2. When subsequent pairs come up, you check your sets for existence of
either word.
3. If either exists, put them in the set, else do what you did in #1.
4. If both exist, merge the sets they're in.

[big large]
[large huge]
[small little]

You end up with: #{big large huge} and #{small little} Now, if you have:

[big large]
[large huge]
[humongous enormous]
[humongous huge]

You get #{big large huge} and #{humongous enormous}, and this becomes
#{big large huge humongous enormous}. (And now I can't stop thinking "Big
McLargeHuge!")

You have to check each set for the presence of a word, of course, and at
some point you might want to optimize for that, but it gets you all the
words that are synonyms. Including:

[with alongside]
[against versus]
[with against]

Where you have a set that contains #{with alongside against verus}.
Because, as often happens in English, a word has two meanings that are not
only different but antonyms.  ("The whisky is agreeable but the meat has
gone bad!")

I have actually used schemes like this in contexts where the synonyms are
exclusive, but it does assume that "big = large = huge", i.e. that there's
no distinction between a direct connection and an inferred one.

On Fri, Apr 9, 2021 at 11:12 PM Nesvarbu Nereikia <nesvarbu.vi...@gmail.com>
wrote:

> Thanks Blake, the map of sets was my first intuition too. But I don't
> think we can derive that big is a synonym of huge from such an index. If
> you look at the example input.
>
> On Saturday, April 10, 2021, Blake Watson <dsblakewat...@gmail.com> wrote:
>
>> In practice I would probably just build a map, word : #setofsynonyms and
>> whenever a synonym was added [a b], I would add b to a's set and a to b's
>> set.
>>
>> Or, even more likely, a vector, because "a" is probably a homonym (if
>> we're talking English) and if "a" is "bank", I need one set of synonyms for
>> "places to put your money" and another set for "the side of a river" and
>> another set for "to hit [an object] off a wall or other barrier". Unless
>> you have some other annotation besides the word so that you can distinguish
>> "bank[1]" from "bank[2]" and "bank[3]".
>>
>> On Fri, Apr 9, 2021 at 7:32 AM SideStep <nesvarbu.vi...@gmail.com> wrote:
>>
>>>
>>> Task is to write a program that can decide whether two words are
>>> synonyms or not.
>>>
>>> I have pairs of synonymous words, E.g.:
>>>
>>>  [big large]
>>>  [large huge]
>>>  [small little]
>>>
>>> We can derive the synonymous relationship indirectly: if big is a
>>> synonym for large and large is a synonym for huge then big is a synonym for
>>> huge.
>>> Being synonyms doesn’t depend on order, e.g. if big is a synonym for
>>> large then large is a synonym for big.
>>>
>>> The program has to answer whether given two words are synonyms or not.
>>>
>>> This seems to me as a good candidate for logic programming, e.g. with
>>> clojure.core.logic.
>>>
>>> a. How to state the input pairs of synonyms as logical
>>> statements/constraints?
>>> b. How to perform a query to find all synonyms of a given word?
>>>
>>> Or perhaps I am yack shaving? What would be a simpler way to solve this?
>>>
>>> This question is also on stackowerflow, if you want to get some points:
>>>
>>>
>>> https://stackoverflow.com/questions/67002758/logic-programming-find-synonyms-of-a-given-word
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/clojure/0cd164b2-56eb-4e99-866d-b1f63522ac52n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/clojure/0cd164b2-56eb-4e99-866d-b1f63522ac52n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Clojure" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/clojure/ILpnkLhK0pM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> clojure+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/clojure/CAJAnwP%3DBZJ%2BeEoEeNv1Yg2eRbsHyVcY7OJm2YmvRLsZ2h8oioA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/clojure/CAJAnwP%3DBZJ%2BeEoEeNv1Yg2eRbsHyVcY7OJm2YmvRLsZ2h8oioA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/CAG-Cp9XqEJNF9egE-2kbcp1muO5_i97Re7AKAtwWR6v62PXzQA%40mail.gmail.com
> <https://groups.google.com/d/msgid/clojure/CAG-Cp9XqEJNF9egE-2kbcp1muO5_i97Re7AKAtwWR6v62PXzQA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAJAnwPkrB7Ghqwx4EPdP8y0GZrjxquOgHawS5PSJKHziaAnr9A%40mail.gmail.com.

Reply via email to