<jupyter_start><jupyter_text>Labelling textLet's assume we have a text dataset that contains some labelled sentences and some unlabelled sentences. For example, we could get the headlines for a bunch of UK news websites (the code for this comes from the great github project [compare-headlines](https://github.com/isobelweinberg/compare-headlines/blob/master/scrape-headlines.ipynb) by [isobelweinberg](https://github.com/isobelweinberg)):<jupyter_code>import requests
from bs4 import BeautifulSoup
import datetime

headlines = []
labels = []

r = requests.get('https://www.theguardian.com/uk').text #get html
soup = BeautifulSoup(r, 'html5lib') #run html through beautiful soup
headlines += [headline.text for headline in
              soup.find_all('span', class_='js-headline-text')][:10]
labels += ['guardian'] * (len(headlines) - len(labels))

soup = BeautifulSoup(requests.get('http://www.dailymail.co.uk/home/index.html').text, 'html5lib')
headlines += [headline.text.replace('\n', '').replace('\xa0', '').strip()
              for headline in soup.find_all(class_="linkro-darkred")][:10]
labels += ['daily mail'] * (len(headlines) - len(labels))

from superintendent import ClassLabeller
import pandas as pd
from IPython import display

labelling_widget = ClassLabeller(
    features=headlines,
    display_func=lambda x: display.display(display.Markdown("# " + x)),
    options=['professional', 'not professional'],
)

labelling_widget<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13568521031207598, 'fraction_numerical': 0.005427408412483039, 'mean_word_length': 5.413043478260869, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '660108', 'license': 'MIT', 'n_tokens_mistral': 473, 'n_tokens_neox': 452, 'n_words': 115, 'path': 'docs/examples/labelling-text.ipynb', 'repo_name': 'vishalbelsare/superintendent', 'size': '1474'}