> ## Documentation Index
> Fetch the complete documentation index at: https://developers.phrase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SRX Overview

## What is SRX?

SRX (Segmentation Rules eXchange) is an XML-based industry standard for defining how source text is split into segments for translation. Phrase TMS uses SRX 2.0 as one of two formats for custom segmentation rules, alongside a simpler XLSX abbreviation-list format.

Segmentation determines where segment boundaries fall (typically at sentence ends), which directly affects translation memory match quality — a job segmented differently than the TM it's leveraged against will get lower or no matches.

For the product-level walkthrough of the Segmentation settings UI, see the [Segmentation Rules (TMS)](https://support.phrase.com/hc/en-us/articles/5709712126876-Segmentation-Rules-TMS) support article. For the full SRX 2.0 specification, see the [Okapi Framework SRX reference](https://okapiframework.org/wiki/index.php/SRX). This guide covers the format basics and how it plugs into the TMS API.

## The two rule formats

| Format | Use case                                                                                                                                                                                                                                               |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| XLSX   | A list of abbreviations that should *not* trigger a segment break (e.g. "Dr.", "approx."). Two variants: `ABBR_UPPER_NUM` (no break before whitespace + a number, symbol, or capitalized word) and `ABBR_NUM` (no break before whitespace + a number). |
| SRX    | Full regular-expression-based rules, for segmentation logic beyond a simple abbreviation exception list.                                                                                                                                               |

Rules are managed per language under **Project Settings → Segmentation** in the TMS web UI, where default rules can be exported as a starting point, and custom rules uploaded as primary or secondary rule sets. Segmentation rules are applied at job import time.

<Note>
  Phrase's SRX rules are character-based: only a single character can act as the segment separator. A group of characters (e.g. a tag like `<p>`) can't be used as a separator.
</Note>

## SRX 2.0 structure

An SRX document has a `header` (global options) and a `body` (the rules):

```xml theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<srx xmlns="http://www.lisa.org/srx20" version="2.0">
  <header segmentsubflows="yes" cascade="no">
    <formathandle type="start" include="no"/>
    <formathandle type="end" include="yes"/>
    <formathandle type="isolated" include="no"/>
  </header>
  <body>
    <languagerules>
      <languagerule languagerulename="default">
        <rule break="no">
          <beforebreak>([A-Z]\.){2,}</beforebreak>
          <afterbreak>\s</afterbreak>
        </rule>
        <rule break="yes">
          <beforebreak>\.</beforebreak>
          <afterbreak>\s</afterbreak>
        </rule>
      </languagerule>
    </languagerules>
    <maprules>
      <languagemap languagepattern=".*" languagerulename="default"/>
    </maprules>
  </body>
</srx>
```

* **`header`** — `cascade` controls whether more than one matching `languagemap` can apply its rules in sequence (`yes`) or only the first match is used (`no`, the SRX 1.0-compatible default). `segmentsubflows` controls whether text inside sub-flows (e.g. footnotes) is segmented too. `formathandle` controls whether inline formatting codes at the start/end/isolated position of a segment are included in it.
* **`languagerules`** — one or more named groups of `rule` elements, evaluated top to bottom. Each rule is either `break="yes"` (this is a valid segment boundary) or `break="no"` (suppress a break here, even if a later rule would otherwise break). A rule matches when the text immediately before the candidate break point matches `beforebreak` and the text immediately after it matches `afterbreak`.
* **`maprules`** — maps a language code pattern (`languagemap languagepattern`, a regex like `.*` or `(DE|de).*`) to one of the named `languagerule` groups, so different languages can use different rule sets.

The example above is the canonical default rule set: break after a period followed by whitespace, *unless* the period follows a run of single capital letters with periods (e.g. don't break after "U.S." or "U.K.").

### Example: a language-specific exception

To add a German-only exception for "Co." (as in "GmbH & Co. KG") not ending a sentence, add a second `languagerule` group and map it to German locales:

```xml theme={null}
<languagerules>
  <languagerule languagerulename="German">
    <rule break="no">
      <beforebreak>\bCo\.</beforebreak>
      <afterbreak>\s</afterbreak>
    </rule>
    <rule break="yes">
      <beforebreak>\.</beforebreak>
      <afterbreak>\s</afterbreak>
    </rule>
  </languagerule>
</languagerules>
<maprules>
  <languagemap languagepattern="(DE|de).*" languagerulename="German"/>
</maprules>
```

Rule order matters: the `break="no"` rule for "Co." is listed before the general `break="yes"` rule, so it takes precedence at that position.

## Working with segmentation rules via the API

| Task                                                       | API operation                                                                                                |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| List segmentation rules                                    | [List segmentation rules](/en/api/tms/latest/segmentation-rules/list-segmentation-rules)                     |
| Create a segmentation rule                                 | [Create segmentation rule](/en/api/tms/latest/segmentation-rules/create-segmentation-rule)                   |
| Get a segmentation rule                                    | [Get segmentation rule](/en/api/tms/latest/segmentation-rules/get-segmentation-rule)                         |
| Edit a segmentation rule                                   | [Edit segmentation rule](/en/api/tms/latest/segmentation-rules/edit-segmentation-rule)                       |
| Export a segmentation rule (download its SRX/XLSX file)    | [Export segmentation rule](/en/api/tms/latest/segmentation-rules/export-segmentation-rule)                   |
| Export the default rules for a locale, as a starting point | [Export default segmentation rules](/en/api/tms/latest/segmentation-rules/export-default-segmentation-rules) |
| Replace a rule's underlying file                           | [Replace segmentation rule file](/en/api/tms/latest/segmentation-rules/replace-segmentation-rule-file)       |

<Note>
  The same actions are available from the TMS web UI under **Project Settings → Segmentation**.
</Note>
