# Path: semantics/util.py
# def text2int(textnum):
#     """From recursive at
#     http://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers-python
# 
#     Converts number words to integers.
#     """
#     numwords = {}
#     units = [
#              "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
#              "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
#              "sixteen", "seventeen", "eighteen", "nineteen",
#              ]
# 
#     tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
# 
#     scales = ["hundred", "thousand", "million", "billion", "trillion"]
# 
#     numwords["and"] = (1, 0)
#     for idx, word in enumerate(units):
#         numwords[word] = (1, idx)
#     for idx, word in enumerate(tens):
#         numwords[word] = (1, idx * 10)
#     for idx, word in enumerate(scales):
#         numwords[word] = (10 ** (idx * 3 or 2), 0)
# 
#     current = result = 0
#     for word in textnum.split():
#         if word not in numwords:
#             return None
# 
#         scale, increment = numwords[word]
#         current = current * scale + increment
#         if scale > 100:
#             result += current
#             current = 0
# 
#     return result + current
# 
# def is_pronoun(word):
#     """Return whether a word is a pronoun."""
#     return word.lower() in PRONOUNS if word else False


from semantics.util import text2int, is_pronoun
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Entity(object):
    """Parent class of entities"""

    TYPES = ['Object', 'Location']
    TYPE_ID = -1  # Subclasses should override TYPE_ID

    def __init__(self, name=None, description=None):
        self.name = name
        self.quantifier = Quantifier()
        # Using mutable object as default argument causes
        # it to be aliased across instances
        self.description = description if description is not None else []

    def merge(self, other):
        """Merge this entity with another entity"""
        if other.name is not None:
            self.name = other.name
        self.quantifier.merge(other.quantifier)
        self.description.extend(other.description)

    def readable(self, case=True):
        # case: true for subject false for object
        if self.name == '*':
            return 'I' if case else 'me'

# Path: semantics/util.py
# def text2int(textnum):
#     """From recursive at
#     http://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers-python
# 
#     Converts number words to integers.
#     """
#     numwords = {}
#     units = [
#              "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
#              "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
#              "sixteen", "seventeen", "eighteen", "nineteen",
#              ]
# 
#     tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
# 
#     scales = ["hundred", "thousand", "million", "billion", "trillion"]
# 
#     numwords["and"] = (1, 0)
#     for idx, word in enumerate(units):
#         numwords[word] = (1, idx)
#     for idx, word in enumerate(tens):
#         numwords[word] = (1, idx * 10)
#     for idx, word in enumerate(scales):
#         numwords[word] = (10 ** (idx * 3 or 2), 0)
# 
#     current = result = 0
#     for word in textnum.split():
#         if word not in numwords:
#             return None
# 
#         scale, increment = numwords[word]
#         current = current * scale + increment
#         if scale > 100:
#             result += current
#             current = 0
# 
#     return result + current
# 
# def is_pronoun(word):
#     """Return whether a word is a pronoun."""
#     return word.lower() in PRONOUNS if word else False


# Path: semantics/new_structures.py
from semantics.util import text2int, is_pronoun

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Entity(object):
    """Parent class of entities"""

    TYPES = ['Object', 'Location']
    TYPE_ID = -1  # Subclasses should override TYPE_ID

    def __init__(self, name=None, description=None):
        self.name = name
        self.quantifier = Quantifier()
        # Using mutable object as default argument causes
        # it to be aliased across instances
        self.description = description if description is not None else []

    def merge(self, other):
        """Merge this entity with another entity"""
        if other.name is not None:
            self.name = other.name
        self.quantifier.merge(other.quantifier)
        self.description.extend(other.description)

    def readable(self, case=True):
        # case: true for subject false for object
        if self.name == '*':
            return 'I' if case else 'me'

        elif is_pronoun(self.name):