예제 #1
0
파일: wordnet.php 프로젝트: robmyers/paintr
function wordnet_tags_synonims($tags)
{
    $synonims = array();
    foreach ($tags as $tag) {
        $tag_synonims = wordnet_tag_synonims($tag);
        $synonims = array_merge($synonims, $tag_synonims);
    }
    return $synonims;
}
예제 #2
0
function flickr_photo_from_tags($tags)
{
    $photos = flickr_tag_search($tags, 10);
    $photos_count = $photos->getCount();
    //echo "Count: " . $photos_count . "\n";
    if ($photos_count == 0) {
        //TODO: It's here that we add the intelligense
        //TODO: Currently we get too many new tags too fast,
        //TODO: Then just fall back to "art" if that fails.
        //TODO: Move to paintr.php
        $generalised_tags = wordnet_tag_synonims($tags);
        $photos = flickr_tag_search($generalised_tags, 10);
        $photos_count = $photos->getCount();
        if ($photos_count == 0) {
            $photos = flickr_tag_search(array("art"), 10);
            $photos_count = $photos->getCount();
            if ($photos_count == 0) {
                throw new Exception("No photos at flickr match requested tags.");
            }
        }
    }
    return flickr_photo($photos, 1);
}