2

我已经使用此代码来获取定义:

//assuming you've connected to your MySQL db
$word=$_GET['s']; //This variable stores the value given through url
if (ctype_alpha($word)){ // If it's alphabetical
  $word_clean=mysql_real_escape_string($word); //Sanitize it for MySQL
}else{
  //Not a valid word, error handle
  exit();
}
$query='SELECT wordno FROM word WHERE lemma=`$word_clean` LIMIT 1';
$result=mysql_query($query);


$query='SELECT synsetno FROM sense WHERE wordno=`$wordno`';


$query='SELECT definition FROM synset WHERE synsetno=`$synset`';

但是现在我想获得该词的同义词和类似词($word);

4

2 回答 2

5
SELECT  a.lemma, c.definition
FROM    word a
        INNER JOIN sense b
            ON a.wordno = b.wordNo
        INNER JOIN synset c
            ON b.synsetno = c. synsetno
WHERE   a.lemma = 'valueHere'

要全面了解联接,请访问以下链接:

于 2013-01-31T07:57:42.630 回答
2

使用带有 SQL 的 wordnet v3.0 快速获取同义词/相似词的方法:

SELECT w.lemma
FROM words AS w 
LEFT JOIN senses AS s ON s.wordid = w.wordid
LEFT JOIN senses AS s2 ON s2.synsetid = s.synsetid
LEFT JOIN words AS w2 ON w2.wordid = s2.wordid
WHERE w.lemma <> 'coder' 
AND w2.lemma = 'coder'
GROUP BY w.lemma
ORDER BY s.synsetid
于 2015-06-11T15:34:05.120 回答