#Emoticon_RE = "|".join([Happy_RE,Sad_RE,Wink_RE,Tongue_RE,Other_RE])
#Emoticon_RE = mycompile(Emoticon_RE)

def analyze_tweet(text):
  h= Happy_RE.search(text)
  s= Sad_RE.search(text)
  if h and s: return "BOTH_HS"
  if h: return "HAPPY"
  if s: return "SAD"
  return "NA"

  # more complex & harder, so disabled for now
  #w= Wink_RE.search(text)
  #t= Tongue_RE.search(text)
  #a= Other_RE.search(text)
  #h,w,s,t,a = [bool(x) for x in [h,w,s,t,a]]
  #if sum([h,w,s,t,a])>1: return "MULTIPLE"
  #if sum([h,w,s,t,a])==1:
  #  if h: return "HAPPY"
  #  if s: return "SAD"
  #  if w: return "WINK"
  #  if a: return "OTHER"
  #  if t: return "TONGUE"
  #return "NA"

if __name__=='__main__':
  for line in sys.stdin:
    import sane_re
    sane_re._S(line[:-1]).show_match(Emoticon_RE, numbers=False)
    #print(analyze_tweet(line.strip()), line.strip(), sep="\t")
Exemplo n.º 2
0
    s = Sad_RE.search(text)
    if h and s:
        return "BOTH_HS"
    if h:
        return "HAPPY"
    if s:
        return "SAD"
    return "NA"

    # more complex & harder, so disabled for now
    # w= Wink_RE.search(text)
    # t= Tongue_RE.search(text)
    # a= Other_RE.search(text)
    # h,w,s,t,a = [bool(x) for x in [h,w,s,t,a]]
    # if sum([h,w,s,t,a])>1: return "MULTIPLE"
    # if sum([h,w,s,t,a])==1:
    #  if h: return "HAPPY"
    #  if s: return "SAD"
    #  if w: return "WINK"
    #  if a: return "OTHER"
    #  if t: return "TONGUE"
    # return "NA"


if __name__ == '__main__':
    for line in sys.stdin:
        import sane_re

        sane_re._S(line[:-1]).show_match(Emoticon_RE, numbers=False)
        # print(analyze_tweet(line.strip()), line.strip(), sep="\t")
Exemplo n.º 3
0
def main():
    for line in sys.stdin:
        import sane_re
        sane_re._S(line[:-1]).show_match(Emoticon_RE, numbers=False)