: New:

In the constructor notes for today's Puzzmo crossword, Zhouqin Burnikel says her original gimmick idea (not used) was people whose names had a fruit-word and a season-word. But she could only find one example, so she used a different theme instead.

That got me thinking, so I wrote a little script that looked through my phrase list for two-word phrases and used wordnet to detect fruit-words and season-words. Then I eyeballed the resulting list of fruit-season phrases to see which might be names. The program overlooked the fruit-season name that Zhouqin Burnikel found. (My phrase list doesn't know that name.) But it did find: Jack Spring (an athlete), Jack Winter (a TV writer). Wordnet says that "jack" can mean "jackfruit", and who am I to disagree?

Anyhow, here's the little script I wrote. I put it here not because I feel it's amazing, but because my previous wordnet-use blogposts fell out of Google's index, so when I went searching for past examples, I ended up having to grep around my hard drive like an animal. Anyhow, behold the majesty:

from nltk.corpus import wordnet

FRUIT = wordnet.synset('edible_fruit.n.01')
SEASON = wordnet.synset('season.n.02')

already = {}
is_fruit = {}
is_season = {}

def categorize(word):
    if word in already: return
    sss = wordnet.synsets(word)
    fruity = [ss for ss in sss if FRUIT in ss.hypernyms()]
    seasonal = [ss for ss in sss if SEASON in ss.hypernyms()]
    if len(fruity): is_fruit[word] = True
    if len(seasonal): is_season[word] = True

for line in open("Phrases_20240103_085450.txt"):
    score_s, phrase = line.strip().split("\t")
    words = phrase.split()
    if len(words) != 2: continue
    w1, w2 = words
    categorize(w1)
    categorize(w2)
    if (w1 in is_fruit and w2 in is_season) or (w1 in is_season and w2 in is_fruit):
        print(w1, w2)

Tags: puzzle scene words programming

lahosken@gmail.com

Tags