Wordnet sqlite Synonyms and Samples

前端 未结 2 1357
后悔当初
后悔当初 2021-01-27 16:20

I am trying to get the list of Synonyms and Samples given the wordid. After a lot of trial and error I can get the samples for all the synsets but not the actual synonyms. Here

相关标签:
2条回答
  • 2021-01-27 16:36

    I'm not sure I exactly understand the question, but wouldn't something like this work?

    SELECT s1.wordid, s1.synsetid, s1.sensekey, synsets.definition
       , s2.wordid AS matchedWordID, w.*  -- Additional info not from question's query
    FROM senses AS s1
       LEFT JOIN synsets ON s1.synsetid = synsets.synsetid
       LEFT JOIN senses AS s2 ON s1.synsetid = s2.synsetid AND s1.wordid <> s2.wordid
       LEFT JOIN words AS w ON s2.wordid = w.wordid
    WHERE s1.wordid = 79459
    ;
    

    Note: ... is just short hand for the list of fields you actually want.

    Note#2: You can of course JOIN to samples using the synsets reference, but keep in mind the results would be repeated for every word pair and sample; and it is possible some word pairs may be repeated if they are synonyms in multiple meanings.

    0 讨论(0)
  • 2021-01-27 16:48

    EDIT after schema publication

    It appears that the senses table captures all relationships between each word and all its synsets and should be used in conjunction with inner join with words and synsets tables to to unravel all relationships

    select sen.wordid,
             w.lemma,
             w.mantiq,
           sen.senseid,
           sen.synsetid,
           syn.definition,
    from senses sen 
    inner join words w on sen.wordid = w.wordid
    inner join synsets syn on sen.synsetid = syn.synsetid
    order by sen.wordid, sen.synsetid;
    

    You do not need a LEFT JOIN since the fields you join upon do not appear to be nullable.

    0 讨论(0)
提交回复
热议问题