我已使用此代码获取定义:
//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);
答案 0 :(得分:4)
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'
要充分了解联接知识,请访问以下链接:
答案 1 :(得分:2)
使用wordnet v3.0和SQL获取同义词/类似词的快速方法:
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