コード例 #1
0
ファイル: textvomit.py プロジェクト: coreybobco/Text-Vomit
def main():
    parser = argparse.ArgumentParser(description="order of textual operations")
    parser.add_argument(
        "-m", "--markov", help="use markov chains to generate text output of a specified length", type=int
    )
    parser.add_argument("-c", "--cutup", nargs=2, help="cut up input with cut up block size between X and Y", type=int)
    parser.add_argument("-p", "--poem", help="produce the output in the form of a poem", action="store_true")
    parser.add_argument(
        "-cl",
        "--chatlog",
        help="produce the output in the form of a chatlog (requires chat format)",
        action="store_true",
    )
    parser.add_argument("-sf", "--sample_file", help="grab random excerpt of length X for markov processing", type=int)
    parser.add_argument(
        "-a", "--aphorisms", help="accept input as aphorisms, also output as aphorisms", action="store_true"
    )
    format = False
    while not format:
        format = "poem" if request.args.get("poem") else False
        format = "chat" if request.args.get("chat") else False
        format = "aphorisms" if request.args.get("aphorisms") else False
    args = parser.parse_args()
    markov_obj = Markov_Class()
    cutup_obj = Cutup_Class()
    if args.sample_file:
        word_array = clean(sample_file(args.sample_file, args.aphorisms))
    else:
        word_array = (clean(take_input()), args.chatlog, args.aphorisms)
    if args.markov:
        output_length = args.markov
        print(markov_obj.generate_output(word_array, output_length, format))
    if args.cutup:
        cutup_obj.generate_output(word_array, args.cutup[0], args.cutup[1])
コード例 #2
0
ファイル: server.py プロジェクト: coreybobco/Text-Vomit
def markov():
  cutup_min_size = False if request.args.get('cutupmin') == "false" else int(request.args.get('cutupmin'))
  cutup_max_size = False if request.args.get('cutupmin') == "false" else int(request.args.get('cutupmax'))
  if cutup_min_size:
    cutup = Cutup_Class()
    return cutup.generate_output(clean(request.get_data().decode(encoding='UTF-8'), False, False), cutup_min_size, cutup_max_size)
  else:
    markov = MarkovDictionary()
    wordcount = int(request.args.get('wordcount'))
    format = request.args.get('format')
    return markov.generate_output(clean(request.get_data().decode(encoding='UTF-8'), format), wordcount, format)
コード例 #3
0
def main():
  parser = argparse.ArgumentParser(description="order of textual operations")
  parser.add_argument("-m", "--markov", help="use markov chains to generate text output of a specified length", type=int)
  parser.add_argument("-c", "--cutup", nargs=2, help="cut up input with cut up block size between X and Y", type=int)
  args = parser.parse_args()
  markov_obj = Markov_Class()
  cutup_obj = Cutup_Class()
  word_array = (clean(take_input()))
  if args.markov:
    output_length = args.markov
    markov_obj.generate_output(word_array, output_length)
  if args.cutup:
    cutup_obj.generate_output(word_array, args.cutup[0], args.cutup[1])