Converting SRX to SDL SegmentationRules via Translation Memory API

I've written a C# console app using the Trados Studio (2015) SDK. The purpose is to read in a Segmentation Rules eXchange file and add the rules in it to a LanguageResources file. I am able to add the rules, but when I try to use the resulting LanguageResource with projects in Trados Studio, the new rules don't seem to work. At least part of the problem is that potential "trigger characters" that appear at the end of my PrecedingContext object (e.g., .?!) are escaped in the LR file.

So if the input regex was, for example,

[.?!]\p{P}?

then what I see when I view the rule in Studio is

[.?!]\p{P}\?+

which is not at all the same thing. Is there a way to disable this behavior?

***********

EDIT: This only seems to happen if I edit the rules in Studio, and switch between Basic and Advanced views. The API docs say "if you create a regex that cannot be parsed, Basic View will be disabled". This is the case for most of my SRX rules. My question is, what is doing the parsing here? And are the rules still evaluated/applied in this case?

Parents Reply
  • I think I've solved it, actually, but let me see if I can send you the LanguageResource and a test file so you can confirm/reproduce if you want to. I don't think I can upload files here, but I can E-mail them to you. What's a good E-mail address to use?

    The problem was with how I was handling trigger characters and exceptions - the API documentation says you don't have to specify trigger characters, but it seems like the segmentation rules don't work if you don't have trigger characters specified. Also, it wasn't obvious to me that exceptions are assumed to use the same trigger characters as the rule they are associated with. So I guess Studio was trying to parse both the rules and the exceptions and coming up with strange results.

    I made some changes to my SRX document to make the rules more "parse-able", and I added some logic to specify trigger characters for each rule/exception, then only add exceptions whose triggers overlapped with a particular segmentation rule to that rule's exception list. Those changes eliminated the problems I was having.

Children