# Creating Subcorpora

A subcorpus is a corpus you build yourself by filtering one of the Swiss-AL
corpora. It lets you narrow a large collection down to the texts that matter for
your research question — a period, a group of sources, or the documents that
mention a particular word — and analyse that selection with the same tools as
any other corpus.

:::{important}
Creating subcorpora requires a login and a project of your own. Subcorpora are
stored in the project in which you create them. See the
[Quickstart Guide](at-one-glance.md#getting-started).
:::

## Why create a subcorpus?

Some analyses are only possible, or only meaningful, on a selection of texts:

- **Focusing on a topic.** A keyword filter collects all documents that mention,
  for example, *Corona*. Frequencies, contexts, and topics then describe the
  discourse around that term rather than the whole corpus.
- **Comparing groups of sources.** Separate subcorpora for selected media or
  organizations make it possible to compare how they write about the same issue
  (see the [Climate Change case study](oer-case-studies.md)).
- **Restricting the time span.** A subcorpus covering 2020–2022 isolates a phase
  of a debate from what came before and after.
- **Finding texts that contain several terms together.** The search modes can
  combine terms only with OR. A subcorpus with several keywords and the **ALL**
  option returns only documents containing every one of them (AND).
- **Using Keywords.** The [Keywords](explore-corpus.md#keywords) tool works on
  subcorpora only, because it compares your selection with its
  {term}`parent corpus`.

## Step by step

Open the corpus selection menu and select *Create custom corpus*. The wizard leads
you through the filters one step at a time; confirm each step with **Next**.

:::{tip}
The box **Remaining Documents** at the bottom right shows how many documents your
selection currently contains. Below the number it lists whether there are enough
documents to calculate a *Topic Model*, a *Semantic Space*, and *Keywords* (see
[size requirements](#what-is-calculated-for-a-subcorpus)). Watch it as you go: it
tells you early whether a filter is too narrow for the analyses you plan.
:::

### 1. Language and Type

Select the language and the [corpus type](corpora.md#corpus-types) of the corpus
you want to filter. The number in brackets shows how many corpora of that type are
available. [Project corpora](corpora-project.md) are listed under the type of their
data; the *DE Organizational Sepsis Corpus*, for example, appears under
*Organizational*.

### 2. Parent Corpus

Choose the corpus to filter. This becomes the {term}`parent corpus` of your
subcorpus: all documents in the subcorpus come from it, and it serves as the
reference corpus in a keyword analysis.

Choose the parent corpus deliberately. A subcorpus can only be as broad as the
corpus it comes from, and its type determines which categories you can filter by
in the next steps.

```{figure} _static/subcorpus_wizard_language_parent.webp
:alt: Wizard steps 1 and 2 with German and Organizational selected, listing the German organizational corpora as possible parent corpora
:width: 700px
:align: center

Selecting language, corpus type, and parent corpus.
```

### 3–4. Categories

The next two steps filter by the categories into which the parent corpus's sources
are grouped. Which categories appear depends on the corpus type:

| Corpus type | Step 3 | Step 4 |
| --- | --- | --- |
| [Organizational](corpora-organizational.md) | Social System | Field Of Activity |
| [Journalistic](corpora-journalistic.md) | Media Type | Publisher |
| [Parliamentary](corpora-parliamentary.md) | Social System (only *politics*) | Field Of Activity (only *party*) |

For parliamentary corpora, these two steps offer a single category each, so they
do not narrow the selection. To narrow it, use the sources, date range, or keywords in
the following steps.

Tick **All** to keep every category, or select only the ones you need. Within a
step, the selected categories are combined: choosing *civil society* and
*politics* keeps documents from both.

```{figure} _static/subcorpus_wizard_categories.webp
:alt: Wizard steps 3 and 4 for an organizational corpus, with All social systems and the field of activity canton selected; the Remaining Documents box shows 52613 and confirms enough documents for Topic Model, Semantic Space, and Keywords
:width: 700px
:align: center

Filtering an organizational corpus by social system and field of activity.
```

```{figure} _static/subcorpus_wizard_media_publisher.webp
:alt: Wizard steps 3 and 4 for a journalistic corpus, with All selected for media type and publisher; the Remaining Documents box shows 2384267 and confirms enough documents for Topic Model, Semantic Space, and Keywords
:width: 700px
:align: center

Filtering a journalistic corpus by media type and publisher. The box at the bottom
right shows which analyses the current selection is large enough for.
```

### 5. Sources

Select individual sources, for example single newspapers or organizations. Only
sources that belong to the categories chosen before are offered.

### 6. Date Range

Enter a start date under *From* and an end date under *To* to limit the subcorpus
to documents published within that period. The date range cannot extend beyond the
period covered by the parent corpus.

### 7. Keyword Filtering (optional)

Keywords restrict the subcorpus to documents that contain particular words. Type
a keyword into the field and press **Enter** to add it to the keyword list; repeat
for further keywords. If you leave the list empty, no keyword filter is applied.

Enter each keyword as a **lemma**: keyword filtering is case-insensitive and
matches all forms in the word's paradigm, exactly as in
[Quick Search](quick-search.md). Entering *Impfung*, for example, also finds
*Impfungen*.

With several keywords, choose under *Select document if* how they are combined:

| Option | Logic | Returns |
| --- | --- | --- |
| **ALL of the keywords appear in document** (default) | AND | only documents containing every keyword |
| **ANY of the keywords appear in document** | OR | documents containing at least one of the keywords |

```{figure} _static/subcorpus_wizard_date_keywords.webp
:alt: Wizard steps 6 and 7 with a date range from 01.01.2022 to 18.11.2024, an empty keyword field, and the option ALL selected
:width: 700px
:align: center

Setting the date range and adding keywords.
```

:::{tip}
Use only **single-word keywords**; multiword expressions are not supported in the
wizard. For those, [create the subcorpus from a search](#creating-a-subcorpus-from-a-search). To
capture spelling variants (*Covid*, *Corona*, *Coronavirus*), enter each variant
as a separate keyword and switch from the default **ALL** to **ANY**.
:::

:::{note}
A keyword filter selects whole documents. A document that mentions *Corona* once
in passing is included just as much as one that is entirely about the pandemic.
Check in [Context of Words](search-corpus.md#context-of-words) whether your
subcorpus contains what you expect.
:::

### 8. Save corpus

Give the subcorpus a name that describes the selection, for example
*DE Journalistic — Corona, 2020–2022, daily/online newspapers*. A descriptive name helps
you keep several subcorpora apart and makes it easier to cite your analyses later.

After you save, the platform builds the subcorpus. Click **Go Back to the
Workspace** to return to your analyses; the subcorpus then appears in the corpus
selection menu of your project.


:::{note}
How long processing takes depends on the size of the subcorpus. Calculating the
models for [Topics](explore-corpus.md#topics) and
[Semantic Space](explore-corpus.md#semantic-space) takes a few minutes for very
small subcorpora and up to several hours for very large ones. It can also take
longer when many users are creating subcorpora at the same time.
:::

## Creating a subcorpus from a search

The wizard accepts only single-word keywords. To build a subcorpus around a
multiword expression, a sequence of words, or a more complex pattern, start from a
search instead. All four [Search Corpus](search-corpus.md) tools offer the three
[search modes](search-modes.md) and let you turn the documents matching your query
into a subcorpus:

- [Distribution of Words](search-corpus.md#distribution-of-words)
- [Context of Words](search-corpus.md#context-of-words)
- [Distribution in Documents](search-corpus.md#distribution-in-documents)
- [Common Pairings](search-corpus.md#common-pairings)

| Search mode | Useful for subcorpora around… | Example |
| --- | --- | --- |
| [Quick Search](quick-search.md) | a word in all its inflected forms | *Impfung* |
| [Basic Search](basic-search.md) | an exact word form, alternatives (OR), word beginnings or endings, a part of speech | words starting with *Migration* |
| [Advanced Search](advanced-search.md) | multiword expressions, sequences, regular expressions, annotations, named entities | *No Billag*, *Ehe für alle* |

1. Open a Search Corpus tool and run your query in the search mode you need.
2. Check the hits, for example in [Context of Words](search-corpus.md#context-of-words),
   to make sure the query finds what you mean and not more.
3. Click **Create sub-corpus from query** below the search field. The subcorpus
   contains all documents with at least one hit for the query.

```{figure} _static/create_subcorpus_from_query.webp
:alt: The search field in Common Pairings with the button "Create sub-corpus from query" below it
:width: 600px
:align: center

Creating a subcorpus from a Quick Search query in Common Pairings.
```

Subcorpora created this way behave like any other subcorpus: the same analyses are
calculated, the same [size requirements](#what-is-calculated-for-a-subcorpus)
apply, and the corpus you searched becomes the {term}`parent corpus`.

:::{note}
Record the exact query, including the search mode, as part of
[documenting your subcorpus](#documenting-your-subcorpus). The same string can
return different documents in Quick, Basic, and Advanced Search.
:::

## What is calculated for a subcorpus

When a subcorpus is created, the platform prepares it for analysis. Some of these
steps only run if the subcorpus is large enough:

| Analysis | Requirement | Used by |
| --- | --- | --- |
| Frequencies, contexts, document lists, pairings | none | [Search Corpus](search-corpus.md) tools |
| Keyword analysis against the parent corpus | none | [Keywords](explore-corpus.md#keywords) |
| Topic model with 50 topics | at least **1,000 documents** | [Topics](explore-corpus.md#topics) |
| Word embeddings | at least **10 million tokens** | [Semantic Space](explore-corpus.md#semantic-space) |

:::{important}
Check the number of documents and tokens in [Overview](explore-corpus.md#overview)
after building a subcorpus. If it is below a threshold, the corresponding tool is
not available. In that case, consider widening the selection — a longer time span,
more sources, or **ANY** instead of **ALL**.
:::

## Checking your subcorpus

Before analysing, open [Overview](explore-corpus.md#overview). It shows the parent
corpus, the period, the number of documents and tokens, and the distribution
across sources and years. Ask yourself:

- Does the period match what you intended?
- Are a few sources dominating the selection? A finding about "the media" reads
  differently if most documents come from one outlet.
- Are there years with very few documents that could distort a frequency trend?

## Documenting your subcorpus

The platform does not keep a log of how a subcorpus was defined. Note down the
parent corpus, the date, and every filter you set **while** you build it. This is
what you need to [cite an analysis based on a subcorpus](citing-swiss-al.md#citing-a-subcorpus)
and what allows others to rebuild your selection.

| Record | Example |
| --- | --- |
| Parent corpus | *DE Journalistic Corpus (high reach+regional, 2018–2025)* |
| Date of creation | 6 September 2026 |
| Categories and sources | media type: daily/online newspaper |
| Time span | January 2020 – December 2022 |
| Keywords and combination, or search query and mode | *Corona* (ANY) |
| Size | 4,312 documents; 2.1 million tokens |

:::{seealso}
- [Corpora](corpora.md) — which parent corpora are available
- [Keywords](explore-corpus.md#keywords) — comparing a subcorpus with its parent
- [Citing Swiss-AL](citing-swiss-al.md#citing-a-subcorpus) — how to cite work based on a subcorpus
:::
