Esempio n. 1
0
def revtxt_subkey(review):
    subkey = ""
    if review["revtype"] == "book":
        subkey = safestr(review["author"])
    if review["revtype"] == "music":
        subkey = safestr(review["artist"])
    return subkey
Esempio n. 2
0
def rev_text_from_spec(review, spec):
    txt = ""
    for cc in spec:
        if cc == "s":
            txt = space_conc(txt, revtxt_stars(review))
        elif cc == "r":
            txt = space_conc(txt, review["revtype"])
        elif cc == "t":
            txt = space_conc(txt, revtxt_title(review))
            txt = space_conc(txt, revtxt_subkey(review))
        elif cc == "k":
            txt = space_conc(txt, safestr(review["keywords"]))
        elif cc == "d":
            txt = space_conc(txt, safestr(review["text"]))
        elif cc == "v":
            txt = space_conc(txt, "|")
    return txt
Esempio n. 3
0
def descrip(rev):
    revtext = rev.text or ""
    if revtext:
        # strip any newlines or similar annoyances
        revtext = re.sub('\s+', ' ', revtext)
    text = getTitle(rev)
    subkey = getSubkey(rev)
    if subkey:
        text += " - " + subkey
    assoc = secondaryFieldZip(rev)
    for av in assoc:
        if av[1]:
            text += ", " + safestr(av[1])
    text += ". " + revtext
    text += " " + safestr(rev.keywords)
    if len(text) > 150:
        text = text[:150] + "..."
    text = re.sub('\"', '"', text)
    return text
Esempio n. 4
0
def revtxt_title(review):
    names = ["yum", "activity", "other"]
    if review["revtype"] in names:
        return safestr(review["name"])
    return safestr(review["title"])