Segmentazione Personalizzata

In questo caso, puoi definire le tue regole di segmentazione per ogni file sorgente individualmente, usando lo standard SRX 2.0. Although, there might be situations when the default segmentation rules segment source files in contrast to the desired expectations. Each time you upload XML, HTML, MD, or any other source files without a key-value structure, the predefined segmentation rules (SRX 2.0) are used for automatic content segmentation.

Cambiare Segmentazione

You can change segmentation in Sources > Files.

  1. Open the project where you’d like to adjust the segmentation rules and go to Sources > Files.
  2. Click (or right-click) on the needed file and select Settings.
  3. In the appeared dialog, switch to the Parser configuration tab.
  4. Select Enable content segmentation and Use custom segmentation rules.
  5. Paste your SRX segmentation rules and click Save.

After you save your new segmentation rules, your source file will be automatically reimported and segmented according to these new rules.

Esempi di Segmentazione

Note: Regular expressions used in SRX rules must be compatible with PHP (PCRE2) and Node.js.

Un file SRX tipico somiglia al seguente:

<?xml version="1.0" encoding="UTF-8"?>
<srx version="2.0" 
    xmlns="http://www.lisa.org/srx20"
    xsi:schemaLocation="http://www.lisa.org/srx20 srx20.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <header segmentsubflows="yes" cascade="yes">
        <formathandle type="start" include="no"/>
        <formathandle type="end" include="yes"/>
        <formathandle type="isolated" include="yes"/>
    </header>
    <body>
        <languagerules>
            <languagerule languagerulename="Default">
                <!-- Common rules for most languages -->
                <rule break="no">
                    <beforebreak>^\s*[0-9]+\.</beforebreak>
                    <afterbreak>\s</afterbreak>
                </rule>
                <rule break="yes">
                    <afterbreak>\n</afterbreak>
                </rule>
                <rule break="yes">
                    <beforebreak>[\.\?!]+</beforebreak>
                    <afterbreak>\s</afterbreak>
                </rule>
            </languagerule>
        </languagerules>
        <maprules>
            <!-- List exceptions first -->
            <languagemap languagepattern="[Ee][Nn].*" languagerulename="English"/>
            <languagemap languagepattern="[Ff][Rr].*" languagerulename="French"/>
            <!-- Japanese breaking rules -->
            <languagemap languagepattern="[Jj][Aa].*" languagerulename="Japanese"/>
            <!-- Common breaking rules -->
            <languagemap languagepattern=".*" languagerulename="Default"/>
        </maprules>
    </body>
</srx>

Cambiare il Separatore della Frase per le Lingue Asiatiche

Solitamente, l’interruzione completa è usata come separatore della frase. Although, for some Asian languages, it’s not the case. For example, the typical sentence separator in Chinese is an ideographic full stop (). For such cases, you may want to use the following ruleset:

<rule break="yes">
    <beforebreak>[\x3002]+</beforebreak>
    <afterbreak></afterbreak>
</rule>

Spezzare il Testo in Parti Più Piccole

In the following simple sentence, we’ll break down a case when segmenting one text piece into two (or more) strings is necessary.

Testo con regole di segmentazione predefinite:

Questa è la prima parte dell'esempio di frase e questa è la seconda parte.

Testo con le nuove regole di segmentazione:

Questa è la prima frase della frase d'esempio
e questa è la seconda parte.

For this particular case, the following ruleset will break the initial sentence into two parts:

<rule break="yes">
    <beforebreak>frase</beforebreak>
    <afterbreak>\u0020</afterbreak>
</rule>

Creare Regole di Segmentazione con gli Editor SRX

Le regole di segmentazione SRX possono esser create e mantenute con l’aiuto di strumenti come Ratel. Ha un’interfaccia visiva dove puoi generare le regole di segmentazione da zero o modificare quelle esistenti.

Cercare Assistenza

Serve aiuto per configurare le tue regole di segmentazione personalizzate o hai qualche domanda? Contatta il Team di Supporto.

Questo articolo è stato utile?