def safe_int(num):
    """Transform a string into int type with safety."""
    # this function is mainly designed for elasticsearch
    # since there are lots of bad int types
    num = num.strip()
    if '.' in num:
        # when the num is something like: `88.`
        return int(float(num))
    return int(num)