2 *******************************************************************************
3 * Copyright (C) 2014-2015, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
8 #include "unicode/utypes.h"
9 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION
13 #include "unicode/filteredbrk.h"
14 #include "unicode/ucharstriebuilder.h"
15 #include "unicode/ures.h"
17 #include "uresimp.h" // ures_getByKeyWithFallback
18 #include "ubrkimpl.h" // U_ICUDATA_BRKITR
30 static void _fb_trace(const char *m
, const UnicodeString
*s
, UBool b
, int32_t d
, const char *f
, int l
) {
33 s
->extract(0,s
->length(),buf
,2048);
37 fprintf(stderr
,"%s:%d: %s. s='%s'(%p), b=%c, d=%d\n",
38 f
, l
, m
, buf
, (const void*)s
, b
?'T':'F',(int)d
);
41 #define FB_TRACE(m,s,b,d) _fb_trace(m,s,b,d,__FILE__,__LINE__)
43 #define FB_TRACE(m,s,b,d)
46 static int8_t U_CALLCONV
compareUnicodeString(UElement t1
, UElement t2
) {
47 const UnicodeString
&a
= *(const UnicodeString
*)t1
.pointer
;
48 const UnicodeString
&b
= *(const UnicodeString
*)t2
.pointer
;
53 * A UVector which implements a set of strings.
55 class U_COMMON_API UStringSet
: public UVector
{
57 UStringSet(UErrorCode
&status
) : UVector(uprv_deleteUObject
,
58 uhash_compareUnicodeString
,
61 virtual ~UStringSet();
63 * Is this UnicodeSet contained?
65 inline UBool
contains(const UnicodeString
& s
) {
66 return contains((void*) &s
);
68 using UVector::contains
;
70 * Return the ith UnicodeString alias
72 inline const UnicodeString
* getStringAt(int32_t i
) const {
73 return (const UnicodeString
*)elementAt(i
);
76 * Adopt the UnicodeString if not already contained.
77 * Caller no longer owns the pointer in any case.
78 * @return true if adopted successfully, false otherwise (error, or else duplicate)
80 inline UBool
adopt(UnicodeString
*str
, UErrorCode
&status
) {
81 if(U_FAILURE(status
) || contains(*str
)) {
85 sortedInsert(str
, compareUnicodeString
, status
);
86 if(U_FAILURE(status
)) {
95 * @return true if successfully adopted.
97 inline UBool
add(const UnicodeString
& str
, UErrorCode
&status
) {
98 if(U_FAILURE(status
)) return false;
99 UnicodeString
*t
= new UnicodeString(str
);
101 status
= U_MEMORY_ALLOCATION_ERROR
; return false;
103 return adopt(t
, status
);
106 * Remove this string.
107 * @return true if successfully removed, false otherwise (error, or else it wasn't there)
109 inline UBool
remove(const UnicodeString
&s
, UErrorCode
&status
) {
110 if(U_FAILURE(status
)) return false;
111 return removeElement((void*) &s
);
116 * Virtual, won't be inlined
118 UStringSet::~UStringSet() {}
121 static const int32_t kPARTIAL
= (1<<0); //< partial - need to run through forward trie
122 static const int32_t kMATCH
= (1<<1); //< exact match - skip this one.
123 static const int32_t kSuppressInReverse
= (1<<0);
124 static const int32_t kAddToForward
= (1<<1);
125 static const UChar kFULLSTOP
= 0x002E; // '.'
127 class SimpleFilteredSentenceBreakIterator
: public BreakIterator
{
129 SimpleFilteredSentenceBreakIterator(BreakIterator
*adopt
, UCharsTrie
*forwards
, UCharsTrie
*backwards
, UErrorCode
&status
);
130 SimpleFilteredSentenceBreakIterator(const SimpleFilteredSentenceBreakIterator
& other
);
131 virtual ~SimpleFilteredSentenceBreakIterator();
133 LocalPointer
<BreakIterator
> fDelegate
;
134 LocalUTextPointer fText
;
135 LocalPointer
<UCharsTrie
> fBackwardsTrie
; // i.e. ".srM" for Mrs.
136 LocalPointer
<UCharsTrie
> fForwardsPartialTrie
; // Has ".a" for "a.M."
138 /* -- subclass interface -- */
140 /* -- cloning and other subclass stuff -- */
141 virtual BreakIterator
* createBufferClone(void * /*stackBuffer*/,
142 int32_t &/*BufferSize*/,
143 UErrorCode
&status
) {
144 // for now - always deep clone
145 status
= U_SAFECLONE_ALLOCATED_WARNING
;
148 virtual BreakIterator
* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); }
149 virtual UClassID
getDynamicClassID(void) const { return NULL
; }
150 virtual UBool
operator==(const BreakIterator
& o
) const { if(this==&o
) return true; return false; }
152 /* -- text modifying -- */
153 virtual void setText(UText
*text
, UErrorCode
&status
) { fDelegate
->setText(text
,status
); }
154 virtual BreakIterator
&refreshInputText(UText
*input
, UErrorCode
&status
) { fDelegate
->refreshInputText(input
,status
); return *this; }
155 virtual void adoptText(CharacterIterator
* it
) { fDelegate
->adoptText(it
); }
156 virtual void setText(const UnicodeString
&text
) { fDelegate
->setText(text
); }
158 /* -- other functions that are just delegated -- */
159 virtual UText
*getUText(UText
*fillIn
, UErrorCode
&status
) const { return fDelegate
->getUText(fillIn
,status
); }
160 virtual CharacterIterator
& getText(void) const { return fDelegate
->getText(); }
162 /* -- ITERATION -- */
163 virtual int32_t first(void) { return fDelegate
->first(); }
164 virtual UBool
isBoundary(int32_t offset
) { return fDelegate
->isBoundary(offset
); }
165 virtual int32_t current(void) const { return fDelegate
->current(); }
166 virtual int32_t next(int32_t n
) { return fDelegate
->next(n
); } // fallback implementation, undoing r36410
167 virtual int32_t last(void) { return fDelegate
->last(); }
169 virtual int32_t next(void);
170 virtual int32_t following(int32_t offset
);
171 virtual int32_t previous(void);
172 virtual int32_t preceding(int32_t offset
);
175 virtual int32_t nextCore(int32_t n
);
176 virtual int32_t previousCore(int32_t n
);
180 SimpleFilteredSentenceBreakIterator::SimpleFilteredSentenceBreakIterator(const SimpleFilteredSentenceBreakIterator
& other
)
181 : BreakIterator(other
), fDelegate(other
.fDelegate
->clone())
184 TODO: not able to clone Tries. Should be a refcounted hidden master instead.
185 if(other.fBackwardsTrie.isValid()) {
186 fBackwardsTrie.adoptInstead(other.fBackwardsTrie->clone());
188 if(other.fForwardsPartialTrie.isValid()) {
189 fForwardsPartialTrie.adoptInstead(other.fForwardsPartialTrie->clone());
195 SimpleFilteredSentenceBreakIterator::SimpleFilteredSentenceBreakIterator(BreakIterator
*adopt
, UCharsTrie
*forwards
, UCharsTrie
*backwards
, UErrorCode
&status
) :
196 BreakIterator(adopt
->getLocale(ULOC_VALID_LOCALE
,status
),adopt
->getLocale(ULOC_ACTUAL_LOCALE
,status
)),
198 fBackwardsTrie(backwards
),
199 fForwardsPartialTrie(forwards
)
204 SimpleFilteredSentenceBreakIterator::~SimpleFilteredSentenceBreakIterator() {}
206 int32_t SimpleFilteredSentenceBreakIterator::next() {
207 int32_t n
= fDelegate
->next();
211 int32_t SimpleFilteredSentenceBreakIterator::following(int32_t offset
) {
212 int32_t n
= fDelegate
->following(offset
);
216 int32_t SimpleFilteredSentenceBreakIterator::nextCore(int32_t n
) {
217 if(n
== UBRK_DONE
|| // at end or
218 fBackwardsTrie
.isNull()) { // .. no backwards table loaded == no exceptions
221 // OK, do we need to break here?
222 UErrorCode status
= U_ZERO_ERROR
;
224 fText
.adoptInstead(fDelegate
->getUText(fText
.orphan(), status
));
225 int64_t utextLen
= utext_nativeLength(fText
.getAlias());
229 //if(debug2) u_printf("str, native len=%d\n", utext_nativeLength(fText.getAlias()));
230 do { // outer loop runs once per underlying break (from fDelegate).
231 // loops while 'n' points to an exception.
232 utext_setNativeIndex(fText
.getAlias(), n
); // from n..
233 fBackwardsTrie
->reset();
235 //if(debug2) u_printf(" n@ %d\n", n);
236 // Assume a space is following the '.' (so we handle the case: "Mr. /Brown")
237 if((uch
=utext_previous32(fText
.getAlias()))==(UChar32
)0x0020) { // TODO: skip a class of chars here??
238 // TODO only do this the 1st time?
239 //if(debug2) u_printf("skipping prev: |%C| \n", (UChar)uch);
241 //if(debug2) u_printf("not skipping prev: |%C| \n", (UChar)uch);
242 uch
= utext_next32(fText
.getAlias());
243 //if(debug2) u_printf(" -> : |%C| \n", (UChar)uch);
245 UStringTrieResult r
= USTRINGTRIE_INTERMEDIATE_VALUE
;
247 int32_t bestPosn
= -1;
248 int32_t bestValue
= -1;
250 while((uch
=utext_previous32(fText
.getAlias()))!=U_SENTINEL
&& // more to consume backwards and..
251 USTRINGTRIE_HAS_NEXT(r
=fBackwardsTrie
->nextForCodePoint(uch
))) {// more in the trie
252 if(USTRINGTRIE_HAS_VALUE(r
)) { // remember the best match so far
253 bestPosn
= utext_getNativeIndex(fText
.getAlias());
254 bestValue
= fBackwardsTrie
->getValue();
256 //if(debug2) u_printf("rev< /%C/ cont?%d @%d\n", (UChar)uch, r, utext_getNativeIndex(fText.getAlias()));
259 if(USTRINGTRIE_MATCHES(r
)) { // exact match?
260 //if(debug2) u_printf("rev<?/%C/?end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
261 bestValue
= fBackwardsTrie
->getValue();
262 bestPosn
= utext_getNativeIndex(fText
.getAlias());
263 //if(debug2) u_printf("rev<+/%C/+end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
267 //if(debug2) u_printf("rev< /%C/ end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
269 //if(USTRINGTRIE_MATCHES(r)) { // matched - so, now what?
270 //int32_t bestValue = fBackwardsTrie->getValue();
271 ////if(debug2) u_printf("rev< /%C/ matched, skip..%d bestValue=%d\n", (UChar)uch, r, bestValue);
273 if(bestValue
== kMATCH
) { // exact match!
274 //if(debug2) u_printf(" exact backward match\n");
275 n
= fDelegate
->next(); // skip this one. Find the next lowerlevel break.
276 if(n
==UBRK_DONE
|| n
==utextLen
) return n
;
277 continue; // See if the next is another exception.
278 } else if(bestValue
== kPARTIAL
279 && fForwardsPartialTrie
.isValid()) { // make sure there's a forward trie
280 //if(debug2) u_printf(" partial backward match\n");
281 // We matched the "Ph." in "Ph.D." - now we need to run everything through the forwards trie
282 // to see if it matches something going forward.
283 fForwardsPartialTrie
->reset();
284 UStringTrieResult rfwd
= USTRINGTRIE_INTERMEDIATE_VALUE
;
285 utext_setNativeIndex(fText
.getAlias(), bestPosn
); // hope that's close ..
286 //if(debug2) u_printf("Retrying at %d\n", bestPosn);
287 while((uch
=utext_next32(fText
.getAlias()))!=U_SENTINEL
&&
288 USTRINGTRIE_HAS_NEXT(rfwd
=fForwardsPartialTrie
->nextForCodePoint(uch
))) {
289 //if(debug2) u_printf("fwd> /%C/ cont?%d @%d\n", (UChar)uch, rfwd, utext_getNativeIndex(fText.getAlias()));
291 if(USTRINGTRIE_MATCHES(rfwd
)) {
292 //if(debug2) u_printf("fwd> /%C/ == forward match!\n", (UChar)uch);
293 // only full matches here, nothing to check
295 n
= fDelegate
->next();
296 if(n
==UBRK_DONE
|| n
==utextLen
) return n
;
299 //if(debug2) u_printf("fwd> /%C/ no match.\n", (UChar)uch);
300 // no match (no exception) -return the 'underlying' break
304 return n
; // internal error and/or no forwards trie
307 //if(debug2) u_printf("rev< /%C/ .. no match..%d\n", (UChar)uch, r); // no best match
308 return n
; // No match - so exit. Not an exception.
310 } while(n
!= UBRK_DONE
);
314 int32_t SimpleFilteredSentenceBreakIterator::previous() {
315 int32_t n
= fDelegate
->previous();
316 return previousCore(n
);
319 int32_t SimpleFilteredSentenceBreakIterator::preceding(int32_t offset
) {
320 int32_t n
= fDelegate
->preceding(offset
);
321 return previousCore(n
);
324 int32_t SimpleFilteredSentenceBreakIterator::previousCore(int32_t n
) {
325 if(n
== UBRK_DONE
|| n
== 0 || // at end or
326 fBackwardsTrie
.isNull()) { // .. no backwards table loaded == no exceptions
329 // OK, do we need to break here?
330 UErrorCode status
= U_ZERO_ERROR
;
332 fText
.adoptInstead(fDelegate
->getUText(fText
.orphan(), status
));
333 do { // outer loop runs once per underlying break (from fDelegate).
334 // loops while 'n' points to an exception.
335 utext_setNativeIndex(fText
.getAlias(), n
); // from n..
336 fBackwardsTrie
->reset();
338 // Skip over any space preceding the break
339 if((uch
=utext_previous32(fText
.getAlias()))==(UChar32
)0x0020) { // TODO: skip a class of chars here??
340 // TODO only do this the 1st time?
342 //restore what we skipped
343 uch
= utext_next32(fText
.getAlias());
345 UStringTrieResult r
= USTRINGTRIE_INTERMEDIATE_VALUE
;
347 int32_t bestPosn
= -1;
348 int32_t bestValue
= -1;
350 while((uch
=utext_previous32(fText
.getAlias()))!=U_SENTINEL
&& // more to consume backwards and..
351 USTRINGTRIE_HAS_NEXT(r
=fBackwardsTrie
->nextForCodePoint(uch
))) {// more in the trie
352 if(USTRINGTRIE_HAS_VALUE(r
)) { // remember the best match so far
353 bestPosn
= utext_getNativeIndex(fText
.getAlias());
354 bestValue
= fBackwardsTrie
->getValue();
358 if(USTRINGTRIE_MATCHES(r
)) { // exact match?
359 bestValue
= fBackwardsTrie
->getValue();
360 bestPosn
= utext_getNativeIndex(fText
.getAlias());
365 if(bestValue
== kMATCH
) { // exact match!
366 n
= fDelegate
->previous(); // skip this one. Find the next lowerlevel break.
367 if(n
==UBRK_DONE
|| n
==0) return n
;
368 continue; // See if the next is another exception.
369 } else if(bestValue
== kPARTIAL
370 && fForwardsPartialTrie
.isValid()) { // make sure there's a forward trie
371 fForwardsPartialTrie
->reset();
372 UStringTrieResult rfwd
= USTRINGTRIE_INTERMEDIATE_VALUE
;
373 utext_setNativeIndex(fText
.getAlias(), bestPosn
); // hope that's close ..
374 while((uch
=utext_next32(fText
.getAlias()))!=U_SENTINEL
&&
375 USTRINGTRIE_HAS_NEXT(rfwd
=fForwardsPartialTrie
->nextForCodePoint(uch
))) {
377 if(USTRINGTRIE_MATCHES(rfwd
)) {
378 n
= fDelegate
->previous();
379 if(n
==UBRK_DONE
|| n
==0) return n
;
382 // no match (no exception) -return the 'underlying' break
386 return n
; // internal error and/or no forwards trie
389 return n
; // No match - so exit. Not an exception.
391 } while(n
!= UBRK_DONE
);
396 * Concrete implementation of builder class.
398 class U_COMMON_API SimpleFilteredBreakIteratorBuilder
: public FilteredBreakIteratorBuilder
{
400 virtual ~SimpleFilteredBreakIteratorBuilder();
401 SimpleFilteredBreakIteratorBuilder(const Locale
&fromLocale
, UErrorCode
&status
);
402 SimpleFilteredBreakIteratorBuilder(UErrorCode
&status
);
403 virtual UBool
suppressBreakAfter(const UnicodeString
& exception
, UErrorCode
& status
);
404 virtual UBool
unsuppressBreakAfter(const UnicodeString
& exception
, UErrorCode
& status
);
405 virtual BreakIterator
*build(BreakIterator
* adoptBreakIterator
, UErrorCode
& status
);
410 SimpleFilteredBreakIteratorBuilder::~SimpleFilteredBreakIteratorBuilder()
414 SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(UErrorCode
&status
)
419 SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Locale
&fromLocale
, UErrorCode
&status
)
422 if(U_SUCCESS(status
)) {
423 LocalUResourceBundlePointer
b(ures_open(U_ICUDATA_BRKITR
, fromLocale
.getBaseName(), &status
));
424 LocalUResourceBundlePointer
exceptions(ures_getByKeyWithFallback(b
.getAlias(), "exceptions", NULL
, &status
));
425 LocalUResourceBundlePointer
breaks(ures_getByKeyWithFallback(exceptions
.getAlias(), "SentenceBreak", NULL
, &status
));
426 if(U_FAILURE(status
)) return; // leaves the builder empty, if you try to use it.
428 LocalUResourceBundlePointer strs
;
429 UErrorCode subStatus
= status
;
431 strs
.adoptInstead(ures_getNextResource(breaks
.getAlias(), strs
.orphan(), &subStatus
));
432 if(strs
.isValid() && U_SUCCESS(subStatus
)) {
433 UnicodeString
str(ures_getUnicodeString(strs
.getAlias(), &status
));
434 suppressBreakAfter(str
, status
); // load the string
436 } while (strs
.isValid() && U_SUCCESS(subStatus
));
437 if(U_FAILURE(subStatus
)&&subStatus
!=U_INDEX_OUTOFBOUNDS_ERROR
&&U_SUCCESS(status
)) {
444 SimpleFilteredBreakIteratorBuilder::suppressBreakAfter(const UnicodeString
& exception
, UErrorCode
& status
)
446 UBool r
= fSet
.add(exception
, status
);
447 FB_TRACE("suppressBreakAfter",&exception
,r
,0);
452 SimpleFilteredBreakIteratorBuilder::unsuppressBreakAfter(const UnicodeString
& exception
, UErrorCode
& status
)
454 UBool r
= fSet
.remove(exception
, status
);
455 FB_TRACE("unsuppressBreakAfter",&exception
,r
,0);
460 * Jitterbug 2974: MSVC has a bug whereby new X[0] behaves badly.
463 * Note: "new UnicodeString[subCount]" ends up calling global operator new
464 * on MSVC2012 for some reason.
466 static inline UnicodeString
* newUnicodeStringArray(size_t count
) {
467 return new UnicodeString
[count
? count
: 1];
471 SimpleFilteredBreakIteratorBuilder::build(BreakIterator
* adoptBreakIterator
, UErrorCode
& status
) {
472 LocalPointer
<BreakIterator
> adopt(adoptBreakIterator
);
474 LocalPointer
<UCharsTrieBuilder
> builder(new UCharsTrieBuilder(status
), status
);
475 LocalPointer
<UCharsTrieBuilder
> builder2(new UCharsTrieBuilder(status
), status
);
476 if(U_FAILURE(status
)) {
480 int32_t revCount
= 0;
481 int32_t fwdCount
= 0;
483 int32_t subCount
= fSet
.size();
485 UnicodeString
*ustrs_ptr
= newUnicodeStringArray(subCount
);
487 LocalArray
<UnicodeString
> ustrs(ustrs_ptr
);
489 LocalMemory
<int> partials
;
490 partials
.allocateInsteadAndReset(subCount
);
492 LocalPointer
<UCharsTrie
> backwardsTrie
; // i.e. ".srM" for Mrs.
493 LocalPointer
<UCharsTrie
> forwardsPartialTrie
; // Has ".a" for "a.M."
499 const UnicodeString
*abbr
= fSet
.getStringAt(i
);
501 FB_TRACE("build",abbr
,TRUE
,i
);
502 ustrs
[n
] = *abbr
; // copy by value
503 FB_TRACE("ustrs[n]",&ustrs
[n
],TRUE
,i
);
505 FB_TRACE("build",abbr
,FALSE
,i
);
506 status
= U_MEMORY_ALLOCATION_ERROR
;
509 partials
[n
] = 0; // default: not partial
512 // first pass - find partials.
513 for(int i
=0;i
<subCount
;i
++) {
514 int nn
= ustrs
[i
].indexOf(kFULLSTOP
); // TODO: non-'.' abbreviations
515 if(nn
>-1 && (nn
+1)!=ustrs
[i
].length()) {
516 FB_TRACE("partial",&ustrs
[i
],FALSE
,i
);
520 for(int j
=0;j
<subCount
;j
++) {
522 if(ustrs
[i
].compare(0,nn
+1,ustrs
[j
],0,nn
+1)==0) {
523 FB_TRACE("prefix",&ustrs
[j
],FALSE
,nn
+1);
524 //UBool otherIsPartial = ((nn+1)!=ustrs[j].length()); // true if ustrs[j] doesn't end at nn
525 if(partials
[j
]==0) { // hasn't been processed yet
526 partials
[j
] = kSuppressInReverse
| kAddToForward
;
527 FB_TRACE("suppressing",&ustrs
[j
],FALSE
,j
);
528 } else if(partials
[j
] & kSuppressInReverse
) {
529 sameAs
= j
; // the other entry is already in the reverse table.
533 FB_TRACE("for partial same-",&ustrs
[i
],FALSE
,sameAs
);
534 FB_TRACE(" == partial #",&ustrs
[i
],FALSE
,partials
[i
]);
535 UnicodeString
prefix(ustrs
[i
], 0, nn
+1);
536 if(sameAs
== -1 && partials
[i
] == 0) {
537 // first one - add the prefix to the reverse table.
539 builder
->add(prefix
, kPARTIAL
, status
);
541 FB_TRACE("Added partial",&prefix
,FALSE
, i
);
542 FB_TRACE(u_errorName(status
),&ustrs
[i
],FALSE
,i
);
543 partials
[i
] = kSuppressInReverse
| kAddToForward
;
545 FB_TRACE("NOT adding partial",&prefix
,FALSE
, i
);
546 FB_TRACE(u_errorName(status
),&ustrs
[i
],FALSE
,i
);
550 for(int i
=0;i
<subCount
;i
++) {
553 builder
->add(ustrs
[i
], kMATCH
, status
);
555 FB_TRACE(u_errorName(status
), &ustrs
[i
], FALSE
, i
);
557 FB_TRACE("Adding fwd",&ustrs
[i
], FALSE
, i
);
559 // an optimization would be to only add the portion after the '.'
560 // for example, for "Ph.D." we store ".hP" in the reverse table. We could just store "D." in the forward,
561 // instead of "Ph.D." since we already know the "Ph." part is a match.
562 // would need the trie to be able to hold 0-length strings, though.
563 builder2
->add(ustrs
[i
], kMATCH
, status
); // forward
565 //ustrs[i].reverse();
566 ////if(debug2) u_printf("SUPPRESS- not Added(%d): /%S/ status=%s\n",partials[i], ustrs[i].getTerminatedBuffer(), u_errorName(status));
569 FB_TRACE("AbbrCount",NULL
,FALSE
, subCount
);
572 backwardsTrie
.adoptInstead(builder
->build(USTRINGTRIE_BUILD_FAST
, status
));
573 if(U_FAILURE(status
)) {
574 FB_TRACE(u_errorName(status
),NULL
,FALSE
, -1);
580 forwardsPartialTrie
.adoptInstead(builder2
->build(USTRINGTRIE_BUILD_FAST
, status
));
581 if(U_FAILURE(status
)) {
582 FB_TRACE(u_errorName(status
),NULL
,FALSE
, -1);
587 return new SimpleFilteredSentenceBreakIterator(adopt
.orphan(), forwardsPartialTrie
.orphan(), backwardsTrie
.orphan(), status
);
591 // ----------- Base class implementation
593 FilteredBreakIteratorBuilder::FilteredBreakIteratorBuilder() {
596 FilteredBreakIteratorBuilder::~FilteredBreakIteratorBuilder() {
599 FilteredBreakIteratorBuilder
*
600 FilteredBreakIteratorBuilder::createInstance(const Locale
& where
, UErrorCode
& status
) {
601 if(U_FAILURE(status
)) return NULL
;
602 LocalPointer
<FilteredBreakIteratorBuilder
> ret(new SimpleFilteredBreakIteratorBuilder(where
, status
), status
);
603 return (U_SUCCESS(status
))? ret
.orphan(): NULL
;
606 FilteredBreakIteratorBuilder
*
607 FilteredBreakIteratorBuilder::createInstance(UErrorCode
& status
) {
608 if(U_FAILURE(status
)) return NULL
;
609 LocalPointer
<FilteredBreakIteratorBuilder
> ret(new SimpleFilteredBreakIteratorBuilder(status
), status
);
610 return (U_SUCCESS(status
))? ret
.orphan(): NULL
;
615 #endif //#if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BREAK_ITERATION