我正在Java中的nlp项目上工作,我想使用wordnet获得给定形容词的同义词和反义词集。到目前为止,我已经做到了这一点,但是我没有得到所需的输出,它只是同义词和反义词集的列表。
net.didion.jwnl.dictionary.Dictionary dict;
File file = new File("properties.xml");
JWNL.initialize(new FileInputStream(file));
dict = net.didion.jwnl.dictionary.Dictionary.getInstance();
IndexWord indexWord = dict.getIndexWord(POS.ADJECTIVE, "bad");
Synset[] senses = indexWord.getSenses();
for(int i=0;i<senses.length;i++){
Synset set= senses[i];
Word[] words=set.getWords();
for(int k=0;k<words.length;k++){
System.out.println(i+","+k+":"+words[k].getLemma());
}
}
输出
信息:安装字典net.didion.jwnl.dictionary.FileBackedDictionary@70177ecd
好, 满了 好, 好, 可估计的 好, 尊敬的 可敬的 有益的 好, 好, 好, 只是, 直立 熟练 专家, 好, 练习过 精通 熟练的 熟练 好, 亲 , 好, 附近, 可信 , 好, 安全 安全 好, 对 , 成熟的 好, 好(p), 有效, 好, in_effect(p), in_force(p), 好, 好, 认真的 好, 声音 好, 称呼 好, 诚实 , 好, 未损坏 未受破坏的 好,
答案 0 :(得分:0)
您需要过滤答案,
while run:
pygame.time.delay(25)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and man2.x > man2.vel:
man2.x -= man2.vel
if keys[pygame.K_RIGHT] and man2.x < 700 - man2.width - man2.vel:
man2.x += man2.vel
if keys[pygame.K_a] and man.x > man.vel:
man.x -= man.vel
if keys[pygame.K_d] and man.x < 700 - man.width - man.vel:
man.x += man.vel
if not man.IsJump and keys[pygame.K_w]:
man.IsJump = True
man.JumpCount = 10
if not man2.IsJump and keys[pygame.K_UP]:
man2.IsJump = True
man2.JumpCount = 10
man.update()
man2.update()
pygame.draw.rect(win, red, (man.x, man.y, man.width, man.height))
pygame.draw.rect(win, green, (man2.x, man2.y, man2.width, man2.height))
drawbg()
pygame.quit()