Merge "Update input checking logic for adding/removing n-gram."