<commit_before>from .models import Span, AnnotationKeySet, AnnotationKey, Label
from itertools import chain
from utils import tokens_to_ngrams

def delete_labels(session, annotation_key_set_name):
    """
    Deletes the AnnotationKeySet with the provided name,
    all AnnotationKeys within it, and all Labels associated with these AnnotationKeys.
    """
    # Get AnnotationKeySet
    try:
        key_set = session.query(AnnotationKeySet).filter(AnnotationKeySet.name == annotation_key_set_name).one()
    except NoResultFound:
        print "AnnotationKeySet %s not found." % annotation_key_set_name
        return False

    print "Deleting Labels..."
    keys_q  = session.query(AnnotationKey).filter(AnnotationKey.sets.contains(key_set))
    keys_sq = keys_q.subquery()
    for label in session.query(Label).filter(keys_sq.c.id.contains(Label.key_id)):
        session.delete(label)
            
    print "Deleting AnnotationKeys..."
    for key in keys_q:
        session.delete(key)
            
    print "Deleting AnnotationKeySet..."
    session.delete(key_set)
    session.commit()


def get_text_splits(c):<commit_msg>Typo fix<commit_after>from .models import Span, AnnotationKeySet, AnnotationKey, Label
from itertools import chain
from utils import tokens_to_ngrams
from sqlalchemy.orm.exc import NoResultFound


def delete_labels(session, annotation_key_set_name):
    """
    Deletes the AnnotationKeySet with the provided name,
    all AnnotationKeys within it, and all Labels associated with these AnnotationKeys.
    """
    # Get AnnotationKeySet
    try:
        key_set = session.query(AnnotationKeySet).filter(AnnotationKeySet.name == annotation_key_set_name).one()
    except NoResultFound:
        print "AnnotationKeySet %s not found." % annotation_key_set_name
        return False

    print "Deleting Labels..."
    keys_q  = session.query(AnnotationKey).filter(AnnotationKey.sets.contains(key_set))
    keys_sq = keys_q.subquery()
    for label in session.query(Label).filter(keys_sq.c.id.contains(Label.key_id)):
        session.delete(label)
            
    print "Deleting AnnotationKeys..."
    for key in keys_q:
        session.delete(key)
            
    print "Deleting AnnotationKeySet..."
    session.delete(key_set)
    session.commit()


def get_text_splits(c):
{'fraction_non_alphanumeric': 0.08748375920311824, 'fraction_numerical': 0.0, 'mean_word_length': 3.502923976608187, 'pattern_counts': {'":': 0, '<': 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': '1739925', 'n_tokens_mistral': 694, 'n_tokens_neox': 683, 'n_words': 162}