# Path: pattern/text/en/inflect.py
# def pluralize(word, pos=NOUN, custom={}, classical=True):
#     """ Returns the plural of a given word, e.g., child => children.
#         Handles nouns and adjectives, using classical inflection by default
#         (i.e., where "matrix" pluralizes to "matrices" and not "matrixes").
#         The custom dictionary is for user-defined replacements.
#     """
#     if word in custom:
#         return custom[word]
#     # Recurse genitives.
#     # Remove the apostrophe and any trailing -s,
#     # form the plural of the resultant noun, and then append an apostrophe (dog's => dogs').
#     if word.endswith(("'", "'s")):
#         w = word.rstrip("'s")
#         w = pluralize(w, pos, custom, classical)
#         if w.endswith("s"):
#             return w + "'"
#         else:
#             return w + "'s"
#     # Recurse compound words
#     # (e.g., Postmasters General, mothers-in-law, Roman deities).
#     w = word.replace("-", " ").split(" ")
#     if len(w) > 1:
#         if w[1] == "general" or \
#            w[1] == "General" and \
#            w[0] not in plural_categories["general-generals"]:
#             return word.replace(w[0], pluralize(w[0], pos, custom, classical))
#         elif w[1] in plural_prepositions:
#             return word.replace(w[0], pluralize(w[0], pos, custom, classical))
#         else:
#             return word.replace(w[-1], pluralize(w[-1], pos, custom, classical))
#     # Only a very few number of adjectives inflect.
#     n = range(len(plural_rules))
#     if pos.startswith(ADJECTIVE):
#         n = [0, 1]
#     # Apply pluralization rules.
#     for i in n:
#         for suffix, inflection, category, classic in plural_rules[i]:
#             # A general rule, or a classic rule in classical mode.
#             if category is None:
#                 if not classic or (classic and classical):
#                     if suffix.search(word) is not None:
#                         return suffix.sub(inflection, word)
#             # A rule pertaining to a specific category of words.
#             if category is not None:
#                 if word in plural_categories[category] and (not classic or (classic and classical)):
#                     if suffix.search(word) is not None:
#                         return suffix.sub(inflection, word)
#     return word
# 
# def referenced(word, article=INDEFINITE):
#     """ Returns a string with the article + the word.
#     """
#     return "%s %s" % (_article(word, article), word)


from builtins import str, bytes, dict, int
from builtins import map, zip, filter
from builtins import object, range
from math import log, ceil
from pattern.text.en.inflect import pluralize, referenced
import os
import sys
import re
# http://www.deveiate.org/projects/Linguistics/wiki/English

NONE      = "no"          #  0
PAIR      = "a pair of"   #  2
SEVERAL   = "several"     #  3-7
NUMBER    = "a number of" #  8-17
SCORE     = "a score of"  # 18-22
DOZENS    = "dozens of"   # 22-200
COUNTLESS = "countless"

quantify_custom_plurals = {}


def approximate(word, amount=1, plural={}):
    """ Returns an approximation of the number of given objects.
        Two objects are described as being "a pair",
        smaller than eight is "several",
        smaller than twenty is "a number of",
        smaller than two hundred are "dozens",
        anything bigger is described as being tens or hundreds of thousands or millions.
        For example: approximate("chicken", 100) => "dozens of chickens".
    """
    try:
        p = pluralize(word, custom=plural)
    except:
        raise TypeError("can't pluralize %s (not a string)" % word.__class__.__name__)
    # Anything up to 200.
    if amount == 0:
        return "%s %s" % (NONE, p)
    if amount == 1:

# Path: pattern/text/en/inflect.py
# def pluralize(word, pos=NOUN, custom={}, classical=True):
#     """ Returns the plural of a given word, e.g., child => children.
#         Handles nouns and adjectives, using classical inflection by default
#         (i.e., where "matrix" pluralizes to "matrices" and not "matrixes").
#         The custom dictionary is for user-defined replacements.
#     """
#     if word in custom:
#         return custom[word]
#     # Recurse genitives.
#     # Remove the apostrophe and any trailing -s,
#     # form the plural of the resultant noun, and then append an apostrophe (dog's => dogs').
#     if word.endswith(("'", "'s")):
#         w = word.rstrip("'s")
#         w = pluralize(w, pos, custom, classical)
#         if w.endswith("s"):
#             return w + "'"
#         else:
#             return w + "'s"
#     # Recurse compound words
#     # (e.g., Postmasters General, mothers-in-law, Roman deities).
#     w = word.replace("-", " ").split(" ")
#     if len(w) > 1:
#         if w[1] == "general" or \
#            w[1] == "General" and \
#            w[0] not in plural_categories["general-generals"]:
#             return word.replace(w[0], pluralize(w[0], pos, custom, classical))
#         elif w[1] in plural_prepositions:
#             return word.replace(w[0], pluralize(w[0], pos, custom, classical))
#         else:
#             return word.replace(w[-1], pluralize(w[-1], pos, custom, classical))
#     # Only a very few number of adjectives inflect.
#     n = range(len(plural_rules))
#     if pos.startswith(ADJECTIVE):
#         n = [0, 1]
#     # Apply pluralization rules.
#     for i in n:
#         for suffix, inflection, category, classic in plural_rules[i]:
#             # A general rule, or a classic rule in classical mode.
#             if category is None:
#                 if not classic or (classic and classical):
#                     if suffix.search(word) is not None:
#                         return suffix.sub(inflection, word)
#             # A rule pertaining to a specific category of words.
#             if category is not None:
#                 if word in plural_categories[category] and (not classic or (classic and classical)):
#                     if suffix.search(word) is not None:
#                         return suffix.sub(inflection, word)
#     return word
# 
# def referenced(word, article=INDEFINITE):
#     """ Returns a string with the article + the word.
#     """
#     return "%s %s" % (_article(word, article), word)


# Path: pattern/text/en/inflect_quantify.py
from builtins import str, bytes, dict, int
from builtins import map, zip, filter
from builtins import object, range
from math import log, ceil
from pattern.text.en.inflect import pluralize, referenced
import os
import sys
import re

# http://www.deveiate.org/projects/Linguistics/wiki/English

NONE      = "no"          #  0
PAIR      = "a pair of"   #  2
SEVERAL   = "several"     #  3-7
NUMBER    = "a number of" #  8-17
SCORE     = "a score of"  # 18-22
DOZENS    = "dozens of"   # 22-200
COUNTLESS = "countless"

quantify_custom_plurals = {}


def approximate(word, amount=1, plural={}):
    """ Returns an approximation of the number of given objects.
        Two objects are described as being "a pair",
        smaller than eight is "several",
        smaller than twenty is "a number of",
        smaller than two hundred are "dozens",
        anything bigger is described as being tens or hundreds of thousands or millions.
        For example: approximate("chicken", 100) => "dozens of chickens".
    """
    try:
        p = pluralize(word, custom=plural)
    except:
        raise TypeError("can't pluralize %s (not a string)" % word.__class__.__name__)
    # Anything up to 200.
    if amount == 0:
        return "%s %s" % (NONE, p)
    if amount == 1:

        return referenced(word) # "a" chicken, "an" elephant