def __init__(self, extensions=[]): from curtana.lib.parser_aliases import A, C, D delimited = D(C(":")) self.parser = (C("%") >> call(self.set_env) * delimited * A | C(">") >> call(self.prompt) * delimited * A | C(",") >> call(self.expand_text) * A | C(".") >> call(self.echo_text) * A | C("'") >> call(self.command) * A) Component.__init__(self, extensions)
def __init__(self, extensions=[]): from curtana.lib.parser_aliases import A, C, D delimited = D(C(":")) self.parser = ( C("%") >> call(self.set_env) * delimited * A | C(">") >> call(self.prompt) * delimited * A | C(",") >> call(self.expand_text) * A | C(".") >> call(self.echo_text) * A | C("'") >> call(self.command) * A ) Component.__init__(self, extensions)
def f(env, user, path=None): if path: try: client.faceexpr_classifier = pickle.load(open(path, "r")) except IOError: print "No such file" else: client.faceexpr_classifier = naivebayes.NaiveBayes() client.faceexpr_path = path client.parser_backup = copy.copy(client.tweet_parser) client.add_syntax(C("/") >> S("faceexpr_train ") >> call(train(client)) * AC * A) client.add_syntax(C("/") >> S("faceexpr_classify ") >> call(classify(client)) * A) client.add_syntax(C("/") >> S("faceexpr_save") >> call(save(client))) client.add_syntax(C("/") >> S("faceexpr_save ") >> call(save(client)) * A) client.tweet_parser = (C("!") >> ApplyN(train_and_change_icon(client, user), AC, A) | ApplyN(train_and_change_icon(client, user), R(None), A))
def __init__(self, extensions): from curtana.lib.parser_aliases import A, C, S, AC, D, Z self.tweet_parser = A self.parser = ( C("/") >> ( S("login ") >> component.call(self.twitter_auth) * A | S("connect ") >> component.call(self.listen_timeline) * A | S("disconnect ") >> component.call(self.terminate) | S("reply ") >> component.call(self.post_reply) * D(C(":")) * Z(lambda: self.tweet_parser) ) | C("\\") >> component.call(self.post_tweet) * Z(lambda: self.tweet_parser) | C(":") >> component.call(self.respond) * AC * A) self.respond_parser = \ (C("@") >> component.call(self.reply) * Z(lambda: self.tweet_parser) | C("`") >> component.call(self.unofficialRT) * Z(lambda: self.tweet_parser) | C("r") >> component.call(self.retweet) | C("f") >> component.call(self.favorite) | component.call(self.reply) * Z(lambda: self.tweet_parser)) component.Component.__init__(self, extensions, multithread=True)
def initialize(self, client, env, user): client.add_syntax(C("/") >> S("faceexpr_enable") >> call(start(client))) client.add_syntax(C("/") >> S("faceexpr_enable ") >> call(start(client)) * A) client.add_syntax(C("/") >> S("faceexpr_disable") >> call(stop(client)))
def __init__(self, extensions): from curtana.lib.parser_aliases import A, C, S, AC, D, Z self.tweet_parser = A self.parser = ( C("/") >> (S("login ") >> component.call(self.twitter_auth) * A | S("connect ") >> component.call(self.listen_timeline) * A | S("disconnect ") >> component.call(self.terminate) | S("reply ") >> component.call(self.post_reply) * D(C(":")) * Z(lambda: self.tweet_parser)) | C("\\") >> component.call(self.post_tweet) * Z(lambda: self.tweet_parser) | C(":") >> component.call(self.respond) * AC * A) self.respond_parser = \ (C("@") >> component.call(self.reply) * Z(lambda: self.tweet_parser) | C("`") >> component.call(self.unofficialRT) * Z(lambda: self.tweet_parser) | C("r") >> component.call(self.retweet) | C("f") >> component.call(self.favorite) | component.call(self.reply) * Z(lambda: self.tweet_parser)) component.Component.__init__(self, extensions, multithread=True)