def get_errors()

in qs_cfn_lint_rules/SentenceCase.py [0:0]


    def get_errors(description, spell, custom_dict):
        dict_words = set([])
        title_errors = set([])
        # Remove items from the custom dict from the string
        for pn in custom_dict:
            description = description.replace(pn, "")
        for sentence in description.split("."):
            word_no = 0
            # [OPTIONAL] prefix should not be considered as part of the string, as it is stripped from
            # the deployment guide
            if sentence.startswith('[OPTIONAL] '):
                sentence = sentence.replace('[OPTIONAL] ', '')
            for pn in custom_dict:
                # if sentence starts with a proper noun then we don't need to check for sentence case
                if sentence.startswith(pn):
                    word_no += 1
                sentence = sentence.replace(pn, "")
            if len(sentence.strip()) > 1:
                # Check that first letter of first word is UPPER
                if sentence[0].upper() != sentence[0]:
                    title_errors.add(sentence.split()[0])
                else:
                    for word in re.split('[^a-zA-Z]', sentence):
                        # ignore 0 length words
                        if word:
                            # Fully uppercase words are considered abbreviations
                            if word_no == 0 and word != word.upper():
                                dict_words.add(word)
                            elif word != word.upper():
                                dict_words.add(word)
                                if word[0].isupper():
                                    title_errors.add(word)
                            word_no += 1
        spell_errors = spell.unknown(list(dict_words))
        for s in list(title_errors):
            if s.lower() in spell_errors:
                title_errors.remove(s)
                spell_errors.remove(s.lower())
        return spell_errors, title_errors