예제 #1
0
def get_wikipedia_links():
    subjects = Hesla.objects.all()
    for subject in subjects:
        if not Vazbywikipedia.objects.filter(id_heslo=subject.id_heslo):
            if get_wikipedia_link(subject.heslo):
                print subject.heslo
                link = Vazbywikipedia(id_heslo=subject.id_heslo, uri_wikipedia="".join(["http://cs.wikipedia.org/wiki/", subject.heslo]).encode("utf8"), typ_vazby="exactMatch", overeni=False)
                link.save()
예제 #2
0
def store_verified_wikipedia_links(filename):
    reader = csv.DictReader(open(filename, "r"))
    i = 0
    for line in reader:
        psh_id = line["Tabulka výsledků"].split("/")[-1]
        if line[""] == "1":
            uri_wikipedia=line["Přiřazený link"]
        else:
            uri_wikipedia=line["Správný link"]
        try:
            link = Vazbywikipedia.objects.get(id_heslo=psh_id)
            link.overeni = True
            link.uri_wikipedia = uri_wikipedia
            link.save()
        except ObjectDoesNotExist:
            link = Vazbywikipedia(id_heslo=psh_id, uri_wikipedia=uri_wikipedia, typ_vazby="exactMatch", overeni=True)
            link.save()