Showing posts with label segmentation. Show all posts
Showing posts with label segmentation. Show all posts

Thursday, October 24, 2019

Regular Expressions for Translators: Four Applications in SDL Trados Studio

In regular expressions (regex), a new line break (or soft return) and a tab are represented with the following special characters:


In a program like SDL Trados Studio, regular expressions can be used to:

                                        1) Filter on segments that match a certain regex

                                        2) Find text that matches a regex

                                        3) Create verification settings

                                        4) Add new segmentation rules to a TM

Let's use the new line and tab special characters to look at a few examples of these applications.

1) Filtering on segments that contain a new line break

This is achieved by using the regular Display Filter (found in the Review tab), which has regex enabled by default, or the Advanced Display Filter, where regular expressions must be enabled by checking a box.

Tip: For even more powerful filtering, download the Community Advanced Display Filter from the SDL app store.

So, if we have a document that looks like this:



Entering the "new line" regex character in the Display Filter search box produces the following filtered results:



2) Finding a tab

To do this, the regular expressions checkbox in the Find dialog box must be checked. This example shows the results of the search.





Once we learn that we can use regex in the Find dialog box, a natural question is whether the same can be done in a replace operation. The answer is a bit disappointing: while the Find field accepts all kinds of regular expressions, the regex syntax accepted by the Replace field is very limited, so, in short, no, you can't do the same in the replace field, that is, you can't replace a tab character with a new line character using regex, for example. In fact, if you enter "\n" in the replace field, that will be interpreted literally as "a backslash followed by an n", and that´s exactly what will be used in the replacement.

3) Creating verification settings

SDL Trados Studio's out-of-the-box verification options include the ability to add regex patterns to flag potential errors. In the example below, a rule has been created to tell Studio that when a new line character is found in the source, it should also be present in the target.



With the rule in place, once the verification is run, the program will identify any instances where there is a new line character in the source but not in the target.




4) Adding new segmentation rules to a TM

There are some cases where creating new pattern-based segmentation rules is desirable. A new segmentation rule for line breaks (soft returns), for example, would look like this (there's a dot in the "After break" section, even though it's hard to see):



After the rule has been added to the TM, files that are added to the project will be segmented at every line break, in addition to the usual segmentation. So, for our example above, if we remove the file from the project and add it back after the rule has been added, the new segmentation would look like this:



Final words
While the examples in this article use only the tab and new line characters, all kinds of complex regex patterns can be used in the four features that make use of regular expressions in Studio (display filter, search, verification and segmentation), and while linguists don't need to be computer programmers, investing some time to learn the basics of regex will help them save time and work more efficiently.


 ¡Pregunta por los precios especiales de SDL Trados Studio para México!




Friday, December 11, 2015

Segmentation Exceptions in SDL Trados Studio

In addition to creating custom segmentation rules, Studio allows us to add exceptions to new or existing rules. This post will explain how to do just that in Studio 2015.

A sample use case

In the example below, the translation for "Made in China" will propagate from segment 2 to segment 4, but this is not desirable in Spanish, as the verb needs to be singular in segment 2 and plural in segment 4, a distinction that exists in Spanish but not in English. Furthermore, there is gender to be taken into account, which in this case doesn't matter, but in other segments will make a difference.



Adding an exception to a segmentation rule

Segmentation rules are modified in each TM's settings. For this example, we will go to Project Settings - Language Pairs - All Language Pairs - Translation Memory and Automated Translation, select the appropriate TM and click Settings, then Language Resources - Segmentation Rules.



I will then select the Colon rule and click Edit.

At the bottom of the Edit Segmentation Rule window, select the Add button next to the Exceptions pane, and then the Advanced View button in the window that opens, to get to the Add Rule Exception window.


This is where we will tell Studio when NOT to segment after a colon, so let's keep our source text in mind to make sure we don't miss anything.

Battery: Made in China
Batteries: Made in China

I want Studio to ignore the colon segmentation rule whenever it comes across the phrase "Made in". The part that I need to change in the rule is what comes after the break, that is, when "Made in" appears after a colon, the colon rule should be skipped. It looks simple enough, but there is one little thing to keep in mind: there is also a space after the colon, and if I don't add that, the exception won't work. So what I really need is for the colon segmentation rule to be ignored when "space + Made in" is found after a colon.

\s represents any whitespace in regular expressions, and it's already included in the "After break" pane as shown above, so I just need to add "Made in" right after it.


After clicking OK, I see that the exception has now been added to the rule.


After closing all the open windows, it's time to process the file with the new segmentation. If my file had been added to my project before adding the exception, I will need to remove it, add it back and reprocess it for the exception to take effect.

And here's the resulting segmentation, just what I needed!



This example uses simple text content for the exception, but with regular expressions, even more powerful exceptions can be added to fit a variety of scenarios.












Wednesday, November 25, 2015

Beyond Punctuation: Creating Custom Segmentation Rules in Studio

A freshly created TM in Studio comes with 3 standard segmentation rules, as shown below.


While these rules are enough in most cases, sometimes we'll open a file and wish it were segmented differently, as in this case:


A quick look at this file makes it clear that it would be a lot easier to handle if "Dry Time" and "Wait Time" were in their own separate segments, so a custom segmentation rule would come in handy.

This new rule won't be punctuation-related, but instead, it will be content-related. In other words, I need Studio to create a new segment whenever the text "Wait Time:" or "Dry Time:" is found.

Adding a New Segmentation Rule

To access the segmentation rules, follow the path shown below.


This opens the Segmentation Rules window, where we will add the new rule.


Clicking Advanced View takes us to this window:


This is where we will tell Studio what we want to do. Before proceeding, let's think about what we want to do.


As shown above, we want to add a segment break (represented by the yellow line) right before "Wait Time:" and "Dry Time:", both of which are preceded by a space. In the window above, I need to tell Studio what pattern can be found before the (segment) break and after the break. So, in this example:

Before the break there is a space

and

After the break there is either "Wait Time:" or "Dry Time:"

To tell Studio what I want to do, I will need to use regular expressions, which for this example are not too complicated.


Explanation:

Before break
\s

  • \s is the regular expression character for whitespace


After break
(Wait|Dry) Time:


  • The | indicates alternation, so it's telling Studio to look for either "Wait" or "Dry"
  • The parentheses are used to group the two alternatives, as otherwise Studio would look for "Wait" or "Dry Time:", that is, it would not combine "Wait" and "Time:"
Note that I'm including the colon in the "After break" expression. This is to prevent unwanted segmentation in segments like "Wait Time cannot be longer than Dry Time."

After clicking OK, the rule is now included in the list of segmentation rules.



After closing all the open windows. The new rule is now available to be applied during processing. 

To apply it to my file, I will need to first remove the file from my project, add it again and process it as usual, as shown in this short video.



And that's all there is to it! After re-processing the file, I now have the segmentation I wanted.





Tuesday, September 29, 2015

Sometimes it’s the Little Things: Managing Abbreviations for Better Segmentation

One of the main sentence-level segmentation rules in Studio uses a full stop to indicate the end of a sentence and therefore the end of a segment. For most jobs, this default segmentation works well, but what if our source text looks like this?


Since Studio interprets each of those periods as the end of a sentence, our file will look like this:


If word order is different in the source and target languages, working with this file will mean entering the translation and locking each segment without confirming it, which means the new translations won’t be added to the TM, which will result in losing all concordance and propagation benefits, as well as any potential future leverage. And if the file has hundreds or thousands of segments like this, productivity can be significantly affected.

Luckily, there’s a simple solution to this: adding “ELEC.”, “HYDR.” and “SYS.” (or any relevant abbreviations, of course) to Studio’s list of recognized abbreviations. Basically, Studio will create a new segment after every period, except when that period is used as part of an abbreviation, so we can make use of this feature, as the list of abbreviations can be edited in the Translation Memory’s settings. Here’s how to do it.

First, go to your TM settings, then Language Resources > Abbreviation List, and click Edit.


This opens the Abbreviations list. Scroll to the bottom and add your abbreviations.


After clicking OK 3 times to close the TM settings window, the new abbreviations will now be recognized by the TM and therefore Studio will ignore them when segmenting a file.

Note that this new segmentation cannot be applied to an existing SDLXLIFF file, which is already segmented, so the source file will need to be processed again by either adding it to a project or opening it as a single file, using the TM that contains the new abbreviations.

After doing so, we get the following Studio file for our example above.


Much better!

As a final note, keep in mind that abbreviations are part of the Translation Memory, which means we can customize them as needed, based on our various files and projects.


Wednesday, January 15, 2014

Adding a Soft Return Segmentation Rule to SDL Trados Studio 2014

In a previous post, I discussed how to add a Tab segmentation rule to Studio.

That is pretty straightforward, as the Tab is one of the segmentation options offered in the list of Break characters.

But what if we want to add a new segmentation rule for soft returns? No such option in the dropdown menu, so we need to use a Regex expression. The steps are detailed below.

In order to get to the Segmentation Rules window, we first need to do the following:

Go into Project Settings, All Language Pairs, then Translation Memory Settings:


In the window that opens, select Language Resources on the left, and then Segmentation Rules on the right, then click on Edit:


This brings up one more box. For this example, since I want Studio to create a new segment every time it finds a soft return, I need to choose Add:


To create a segmentation rule for soft returns, add a name in the description field, choose "Anything" in the "Before break" dropdown menu and "Anything" in the "After break" dropdown menu. Since a soft return is not one of the options in the "Break characters" menu, we need to go to the Advanced View by clicking the button to the right of the Description.


 After clicking on Advanced View, we see this:


This is where we add the Regex expression for a soft return, which should look exactly like this (feel free to copy from below and paste into Studio):

.[\n]+


Disclaimer: My knowledge of Regex is extremely limited; I got this expression from one of Paul Filkin's posts in a forum and simply typed it in. Thank you, Paul!

After this, click OK several times to close all the open dialog boxes, and that's it, from now on, in files processed with this TM, a new segment will be created whenever Studio encounters a soft return.






Thursday, October 3, 2013

Quick and Painless Conversion to Bilingual Doc Format with SDL LegIt!

I have posted before about the steps to create a bilingual (or unclean) DOC file.

To use this process, a user needed to have Trados Workbench installed. This was a source of confusion and frustration for many translators, especially for adopters of Studio who never used "the old Trados" and therefore were not familiar with Workbench or didn't have a working Trados 2007 license.

But it looks like thanks to a great little SDL Open Exchange app called LegIt!, Trados Workbench will soon be but a distant memory, at least for this particular process.


Note that SDL LegIt! requires SDL Trados Studio 2014.

The app is extremely simple to use: all it takes is 4 clicks.

1st click:  Choose whether your want to Convert to TTX or Convert to Bilingual Doc

2nd click:  Select your TM
                  Notes:
                  * Only TMs in TMW format can be selected here
                  * The source and target languages are automatically populated from the TM
                  * You can still segment a file with no TM (skip this 2nd click). When no TM is selected, you
                     will have to select the source and target languages manually.

3rd click:  Select your document(s)
                  Notes:
                  * Only DOC (Word 97-2003 Document) files can be bilingual. If your document has a
                     DOCX extension and you have selected "Convert to Bilingual Doc" the conversion will
                     fail and the file will be converted to TTX instead. Go to MS Word and save as DOC first
                     for successful conversion.

4th click:  Convert
                   Notes:
                  * If you forget to do the 1st click and check Convert to Bilingual Doc (or Convert to TTX),
                     nothing will happen when you click Convert, and you won't get an error message, so make
                     sure you have checked either box before clicking the Convert button.



As a final note, keep in mind that this process overwrites your original Word files. However, for each converted file, a .BAK file is added to your original file location. By changing the file extension to .DOC, you will once again have your original, unsegmented source file.


Friday, July 27, 2012

Changing Segmentation in SDL Trados Studio 2011

For those occasions when Studio's standard segmentation won't do, the following steps will help you customize your file's segmentation to your liking.

 Let's say I have a source file that has tabs in it, like this simple Word file:



After adding my file to a project, and translating the first segment, it looks like this:


We can easily see that if the file were segmented differently, I would be able to leverage my translations much better, with each individual country name being on its own separate segment.

To achieve this, I go into Project Settings, then Translation Memory Settings:


In the window that opens, select Language Resources on the left, and then Segmentation Rules on the right, then click on Edit:


This brings up one more box. For this example, since I want Studio to create a new segment every time it finds a tab, I need to choose Add:


To create a segmentation rule based on tabs, I add a name (Tab), choose "Anything" in the "Before break" dropdown menu, "Tab" in the "Break characters" dropdown menu, and "Anything" in the "After break" dropdown menu:


 Click OK several times to close all the open dialog boxes.

Now I go back to my project, remove the Word file I was working on, add it again, prepare it, and this is what I see:


Much better!

From now on, whenever I use this TM, a new segment will be created  whenever there is a tab. If I want to remove this segmentation rule, I simply go back to the Segmentation Rules dialog box, select the rule I created and click on Remove.

This is a simple example using tabs, but Studio is powerful enough to provide a great range of possibilities by playing with the various options provided.