Example #1
0
 def test_99999(self):
     number = 99999
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "yhdeksänkymmentäyhdeksäntuhattayhdeksänsataayhdeksänkymmentäyhdeksän"
     )
Example #2
0
 def test_999999(self):
     number = 999_999
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "yhdeksänsataayhdeksänkymmentäyhdeksäntuhatta"
         "yhdeksänsataayhdeksänkymmentäyhdeksän",
     )
Example #3
0
 def test_287654321004(self):
     number = 287_654_321_004
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "kaksisataakahdeksankymmentäseitsemänmiljardia"
         "kuusisataaviisikymmentäneljämiljoonaa"
         "kolmesataakaksikymmentäyksituhatta"
         "neljä",
     )
Example #4
0
 def test_1234567890(self):
     number = 1_234_567_890
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "miljardi"
         "kaksisataakolmekymmentäneljämiljoonaa"
         "viisisataakuusikymmentäseitsemäntuhatta"
         "kahdeksansataayhdeksänkymmentä",
     )
Example #5
0
 def test_1234567890(self):
     number = 1_234_567_890
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "miljardi"
         "kaksisataakolmekymmentäneljämiljoonaa"
         "viisisataakuusikymmentäseitsemäntuhatta"
         "kahdeksansataayhdeksänkymmentä",
     )
Example #6
0
 def test_287654321004(self):
     number = 287_654_321_004
     word = fino.to_finnish(number)
     self.assertEqual(
         word,
         "kaksisataakahdeksankymmentäseitsemänmiljardia"
         "kuusisataaviisikymmentäneljämiljoonaa"
         "kolmesataakaksikymmentäyksituhatta"
         "neljä",
     )
Example #7
0
def build_tweet(number, reply_to=None):
    tweet = ""
    if reply_to:
        tweet += "@" + reply_to + " "
    tweet += str(number) + " " + fino.to_finnish(number)

    # Truncate?
    if len(tweet) > 280:
        tweet = tweet[: 280 - 1] + "…"

    return tweet
Example #8
0
def check_replies(credentials):
    global TWITTER
    print("Check replies...")
    # TODO remove duplicate
    if TWITTER is None:
        TWITTER = twitter.Twitter(
            auth=twitter.OAuth(
                credentials["oauth_token"],
                credentials["oauth_token_secret"],
                credentials["consumer_key"],
                credentials["consumer_secret"],
            )
        )

    mentions = TWITTER.statuses.mentions_timeline(
        since_id=credentials["last_mention_id"]
    )
    print(len(mentions), " mentions found")
    for i, m in enumerate(reversed(mentions)):
        print("*" * 80)
        print(i)
        print("text: " + m["text"])
        print("in_reply_to_screen_name:", m["in_reply_to_screen_name"])
        print("screen_name:", m["user"]["screen_name"])
        print("ID:", m["id"])
        number = extract_number_from_tweet(m["text"])
        print("Found a number:", number)

        if number is not None:
            # Does the mention already include the Finnish?
            # If so, it's probably an edited retweet, so don't reply
            if fino.to_finnish(number) in m["text"]:
                print("Mention already includes the Finnish, don't reply")
            else:
                tweet = build_tweet(number, reply_to=m["user"]["screen_name"])
                # print(tweet)
                tweet_it(tweet, data, in_reply_to_status_id=m["id"])

        data["last_mention_id"] = m["id"]
        print("Save last mention ID for next time:", data["last_mention_id"])

        if not args.test:
            save_yaml(args.yaml, data)
Example #9
0
 def test_4000biljoonaa(self):
     number = 4000 * 10**12
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljätuhattabiljoonaa")
Example #10
0
 def test_miljardi(self):
     number = 10 ** 9
     word = fino.to_finnish(number)
     self.assertEqual(word, "miljardi")
Example #11
0
 def test_biljoona(self):
     number = 10**12
     word = fino.to_finnish(number)
     self.assertEqual(word, "biljoona")
Example #12
0
 def test_10(self):
     number = 10
     word = fino.to_finnish(number)
     self.assertEqual(word, "kymmenen")
Example #13
0
 def test_20(self):
     number = 20
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksikymmentä")
Example #14
0
 def test_2(self):
     number = 2
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksi")
Example #15
0
 def test_6(self):
     number = 6
     word = fino.to_finnish(number)
     self.assertEqual(word, "kuusi")
Example #16
0
 def test_2(self):
     number = 2
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksi")
Example #17
0
 def test_3(self):
     number = 3
     word = fino.to_finnish(number)
     self.assertEqual(word, "kolme")
Example #18
0
 def test_3sentiljoonaa(self):
     number = 3 * 10 ** 600
     word = fino.to_finnish(number)
     self.assertEqual(word, "kolmesentiljoonaa")
Example #19
0
 def test_range(self):
     # Just check no errors
     for number in range(0, 100_000):
         word = fino.to_finnish(number)
         self.assertNotEqual(word, "en tiedä")
Example #20
0
 def test_sentiljoona(self):
     number = 10 ** 600
     word = fino.to_finnish(number)
     self.assertEqual(word, "sentiljoona")
Example #21
0
 def test_8googolia(self):
     number = 8 * 10 ** 100 + 1
     word = fino.to_finnish(number)
     self.assertEqual(word, "kahdeksangoogoliayksi")
Example #22
0
 def test_googol(self):
     number = 10 ** 100
     word = fino.to_finnish(number)
     self.assertEqual(word, "googol")
Example #23
0
 def test_8googolia(self):
     number = 8 * 10**100 + 1
     word = fino.to_finnish(number)
     self.assertEqual(word, "kahdeksangoogoliayksi")
Example #24
0
 def test_4(self):
     number = 4
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljä")
Example #25
0
 def test_3sentiljoonaa(self):
     number = 3 * 10**600
     word = fino.to_finnish(number)
     self.assertEqual(word, "kolmesentiljoonaa")
Example #26
0
 def test_5(self):
     number = 5
     word = fino.to_finnish(number)
     self.assertEqual(word, "viisi")
Example #27
0
 def test_4(self):
     number = 4
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljä")
Example #28
0
 def test_6(self):
     number = 6
     word = fino.to_finnish(number)
     self.assertEqual(word, "kuusi")
Example #29
0
 def test_8(self):
     number = 8
     word = fino.to_finnish(number)
     self.assertEqual(word, "kahdeksan")
Example #30
0
 def test_7(self):
     number = 7
     word = fino.to_finnish(number)
     self.assertEqual(word, "seitsemän")
Example #31
0
 def test_15(self):
     number = 15
     word = fino.to_finnish(number)
     self.assertEqual(word, "viisitoista")
Example #32
0
 def test_8(self):
     number = 8
     word = fino.to_finnish(number)
     self.assertEqual(word, "kahdeksan")
Example #33
0
 def test_4000biljoonaa(self):
     number = 4000 * 10 ** 12
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljätuhattabiljoonaa")
Example #34
0
 def test_9(self):
     number = 9
     word = fino.to_finnish(number)
     self.assertEqual(word, "yhdeksän")
Example #35
0
 def test_0(self):
     number = 0
     word = fino.to_finnish(number)
     self.assertEqual(word, "nolla")
Example #36
0
 def test_10(self):
     number = 10
     word = fino.to_finnish(number)
     self.assertEqual(word, "kymmenen")
Example #37
0
 def test_2biljoonaa(self):
     number = 2 * 10**12
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksibiljoonaa")
Example #38
0
 def test_11(self):
     number = 11
     word = fino.to_finnish(number)
     self.assertEqual(word, "yksitoista")
Example #39
0
 def test_googol(self):
     number = 10**100
     word = fino.to_finnish(number)
     self.assertEqual(word, "googol")
Example #40
0
 def test_15(self):
     number = 15
     word = fino.to_finnish(number)
     self.assertEqual(word, "viisitoista")
Example #41
0
 def test_sentiljoona(self):
     number = 10**600
     word = fino.to_finnish(number)
     self.assertEqual(word, "sentiljoona")
Example #42
0
 def test_19(self):
     number = 19
     word = fino.to_finnish(number)
     self.assertEqual(word, "yhdeksäntoista")
Example #43
0
 def test_range(self):
     # Just check no errors
     for number in range(0, 100_000):
         word = fino.to_finnish(number)
         self.assertNotEqual(word, "en tiedä")
Example #44
0
 def test_20(self):
     number = 20
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksikymmentä")
Example #45
0
 def test_3(self):
     number = 3
     word = fino.to_finnish(number)
     self.assertEqual(word, "kolme")
Example #46
0
 def test_42(self):
     number = 42
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljäkymmentäkaksi")
Example #47
0
 def test_5(self):
     number = 5
     word = fino.to_finnish(number)
     self.assertEqual(word, "viisi")
Example #48
0
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument("-l",
                        "--limit",
                        type=int,
                        default=1_000_000,
                        help="Upper limit")
    parser.add_argument("-g",
                        "--guesses",
                        type=int,
                        default=3,
                        help="Number of guesses allowed")
    args = parser.parse_args()

    number = random.randrange(args.limit + 1)
    print("What is " + fino.to_finnish(number) + "?")
    # print(number)

    while True:
        guess = input()
        if str(guess) == str(number):
            print("Yes!")
            break
        else:
            print("No!")
            args.guesses -= 1
            if args.guesses > 0:
                print("Guess again!")
            else:
                print(number)
                break
Example #49
0
 def test_7(self):
     number = 7
     word = fino.to_finnish(number)
     self.assertEqual(word, "seitsemän")
Example #50
0
 def test_biljoona(self):
     number = 10 ** 12
     word = fino.to_finnish(number)
     self.assertEqual(word, "biljoona")
Example #51
0
 def test_9(self):
     number = 9
     word = fino.to_finnish(number)
     self.assertEqual(word, "yhdeksän")
Example #52
0
 def test_0(self):
     number = 0
     word = fino.to_finnish(number)
     self.assertEqual(word, "nolla")
Example #53
0
 def test_11(self):
     number = 11
     word = fino.to_finnish(number)
     self.assertEqual(word, "yksitoista")
Example #54
0
 def test_5002010(self):
     number = 5_002_010
     word = fino.to_finnish(number)
     self.assertEqual(word, "viisimiljoonaakaksituhattakymmenen")
Example #55
0
 def test_19(self):
     number = 19
     word = fino.to_finnish(number)
     self.assertEqual(word, "yhdeksäntoista")
Example #56
0
 def test_miljardi(self):
     number = 10**9
     word = fino.to_finnish(number)
     self.assertEqual(word, "miljardi")
Example #57
0
 def test_42(self):
     number = 42
     word = fino.to_finnish(number)
     self.assertEqual(word, "neljäkymmentäkaksi")
Example #58
0
 def test_2biljoonaa(self):
     number = 2 * 10 ** 12
     word = fino.to_finnish(number)
     self.assertEqual(word, "kaksibiljoonaa")
Example #59
0
if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Guess the number.",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument(
        "-l", "--limit", type=int, default=1_000_000, help="Upper limit"
    )
    parser.add_argument(
        "-g", "--guesses", type=int, default=3, help="Number of guesses allowed"
    )
    args = parser.parse_args()

    number = random.randrange(args.limit + 1)
    print("What is " + fino.to_finnish(number) + "?")
    # print(number)

    while True:
        guess = input()
        if str(guess) == str(number):
            print("Yes!")
            break
        else:
            print("No!")
            args.guesses -= 1
            if args.guesses > 0:
                print("Guess again!")
            else:
                print(number)
                break
Example #60
0
 def test_111111(self):
     number = 111_111
     word = fino.to_finnish(number)
     self.assertEqual(word, "satayksitoistatuhattasatayksitoista")