<commit_before>from __future__ import unicode_literals
from prompt_toolkit.completion import Completer, Completion
from cypher import cypher_words


class CypherCompleter(Completer):

    def __init__(self, labels, relationship_types, properties):
        super(CypherCompleter, self).__init__()

        self.labels = labels
        self.relationship_types = relationship_types
        self.properties = properties

    def get_completions(self, document, complete_event):
        chars_before_cursor = document.get_word_before_cursor(WORD=True)

        if not chars_before_cursor:
            return

        word = self.find_last_word(chars_before_cursor)

        if self.most_recent_non_alpha(chars_before_cursor) == ":":
            if self.looking_for_label(chars_before_cursor):
                choices = self.labels
            else:
                choices = self.relationship_types
        elif self.most_recent_non_alpha(chars_before_cursor) == ".":
            choices = self.properties
        elif word:
            choices = cypher_words
        else:
            return

        choices = self.find_matches(word, choices)

        for completion in choices:
            yield Completion(completion, -len(word))

    def find_matches(self, word, choices):
        word = word.lower()
        lower_choices = [x.lower() for x in choices]

        completions = []
<commit_msg>Don't make suggestions inside a string<commit_after>from __future__ import unicode_literals
from prompt_toolkit.completion import Completer, Completion
from cypher import cypher_words


class CypherCompleter(Completer):

    def __init__(self, labels, relationship_types, properties):
        super(CypherCompleter, self).__init__()

        self.labels = labels
        self.relationship_types = relationship_types
        self.properties = properties

    def get_completions(self, document, complete_event):
        chars_before_cursor = document.get_word_before_cursor(WORD=True)

        if not chars_before_cursor:
            return

        word = self.find_last_word(chars_before_cursor)

        if self.most_recent_non_alpha(chars_before_cursor) == ":":
            if self.looking_for_label(chars_before_cursor):
                choices = self.labels
            else:
                choices = self.relationship_types
        elif self.most_recent_non_alpha(chars_before_cursor) == ".":
            choices = self.properties
        elif self.most_recent_non_alpha(chars_before_cursor) in ["\"", "'"]:
            return
        elif word:
            choices = cypher_words
        else:
            return

        choices = self.find_matches(word, choices)

        for completion in choices:
            yield Completion(completion, -len(word))

    def find_matches(self, word, choices):
        word = word.lower()
        lower_choices = [x.lower() for x in choices]

        completions = []

{'fraction_non_alphanumeric': 0.07607573149741824, 'fraction_numerical': 0.0, 'mean_word_length': 2.6054590570719602, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1310335', 'n_tokens_mistral': 830, 'n_tokens_neox': 781, 'n_words': 173}