{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch09-title",
   "metadata": {},
   "source": [
    "# Strings and Text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch09-overview",
   "metadata": {},
   "source": [
    "Strings are sequences of characters, so many sequence ideas from lists and tuples also apply to text.\n",
    "\n",
    "- Strings as immutable sequences\n",
    "- String methods for cleaning and transforming text\n",
    "- Regular expressions for pattern matching\n",
    "- Dictionaries and counters for text analysis\n",
    "- Random text and Markov-style generation\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0900-video",
   "metadata": {},
   "source": [
    "<h2>Chapter Video</h2>\n",
    "\n",
    "This overview introduces strings, string operations, and common string methods for working with text.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/k9TUPpGqYTo\" title=\"Python Tutorial for Beginners 2: Strings - Working with Textual Data\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "```\n",
    "\n",
    "> *[Python Tutorial for Beginners 2: Strings - Working with Textual Data (21:11)](https://youtube.com/watch?v=k9TUPpGqYTo) by Corey Schafer*\n",
    ">\n",
    "> Hosted on YouTube; property of its original creator, embedded here for educational reference only."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch09-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Objectives</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Create, index, slice, and compare strings\n",
    "2. Use string methods to clean, search, split, join, and format text\n",
    "3. Use regular expressions to find and replace text patterns\n",
    "4. Count words and summarize text with dictionaries and `Counter`\n",
    "5. Generate simple random text from word relationships\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch09-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{container} chapter-flow\n",
    "1. {doc}`0801-strings`\n",
    "2. {doc}`0802-regex`\n",
    "3. {doc}`0803-text-analysis`\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch08-glossary",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| # | Term | Explanation |\n",
    "|---:|---|---|\n",
    "| 1 | String | An immutable sequence of text characters. |\n",
    "| 2 | Escape sequence | A backslash-based notation for characters that are hard to type directly. |\n",
    "| 3 | Raw string | A string literal that treats backslashes mostly as ordinary characters. |\n",
    "| 4 | Indexing | Accessing one character from a string by position. |\n",
    "| 5 | Slicing | Creating a substring from a range of positions. |\n",
    "| 6 | String method | A function called on a string object. |\n",
    "| 7 | Case method | A string method that changes or checks capitalization. |\n",
    "| 8 | Splitting | Breaking one string into a list of smaller strings. |\n",
    "| 9 | Joining | Combining strings from an iterable into one string. |\n",
    "| 10 | String formatting | Building strings that include values from variables or expressions. |\n",
    "| 11 | Docstring | A string at the start of a module, function, class, or method that documents it. |\n",
    "| 12 | Regular expression | A pattern language for matching text. |\n",
    "| 13 | `re` module | Python's standard-library module for regular expressions. |\n",
    "| 14 | Match object | An object that stores information about a successful regular expression match. |\n",
    "| 15 | Metacharacter | A character with special meaning in a regular expression. |\n",
    "| 16 | Quantifier | A regular expression symbol that controls how many times a pattern may repeat. |\n",
    "| 17 | Character class | A regular expression pattern that matches one character from a set of choices. |\n",
    "| 18 | Counter | A dictionary-like collection for counting hashable values. |\n",
    "| 19 | Bigram | A sequence of two adjacent words or tokens. |\n",
    "| 20 | Markov analysis | A text-generation approach that predicts the next item from recent context. |\n",
    "| 21 | f-string | A string literal prefixed with `f` that embeds expressions inside `{}`. |\n",
    "| 22 | Anchor | A regular expression element, such as `^` or `$`, that matches a position in the string rather than a character. |\n",
    "| 23 | Word boundary | The position between a word character and a non-word character, matched by `\\b` in a regular expression. |\n",
    "| 24 | Capturing group | A parenthesized part of a regular expression that saves the matched text so it can be extracted or reused. |\n",
    "| 25 | Greedy matching | The default behavior of a quantifier, which matches as many characters as possible. |\n",
    "| 26 | Non-greedy matching | The behavior of a quantifier followed by `?`, which matches as few characters as possible. |\n",
    "| 27 | Lookahead | A regular expression assertion, written `(?=...)` or `(?!...)`, that checks what follows a position without including it in the match. |\n",
    "| 28 | Lookbehind | A regular expression assertion, written `(?<=...)` or `(?<!...)`, that checks what precedes a position without including it in the match. |\n",
    "| 29 | n-gram | A sequence of n adjacent words or tokens, such as a bigram (two) or a trigram (three). |\n",
    "| 30 | Pseudorandom | Describes numbers produced by a deterministic algorithm that look random, such as those from the `random` module. |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0900-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
