Danny Danny - 22 days ago 9
Swift Question

UITextChecker for ru_RU in Swift

I am trying to implement autocomplete for Russian words in Swift 2.0 and I faced with the following problem.

I've implemented the following code to test how UITextChecker() works:

let textChecker = UITextChecker()
let getAvailableLanguages = UITextChecker.availableLanguages()
print(getAvailableLanguages)
let partial = "leo"
let completions = textChecker.completionsForPartialWordRange(NSRange(0..<partial.utf16.count), inString: partial,language: "en_US")
let completions2 = textChecker.guessesForWordRange(NSRange(0..<partial.utf16.count), inString: partial, language: "en_US")
print(completions)
print(completions2)


This code prints the following result and this result looks good for me:

List of languages:

[ru_RU, en_CA, pt_BR, it_IT, ko_KR, nb_NO, de_DE, en_GB, sv_SE, en_AU, en_SG, es_MX, pt_PT, en_IN, fr_FR, es_ES, nl_NL, tr_TR, fi_FI, pl_PL, en_US, da_DK]


completionsForPartialWordRange:

Optional([leonine, leopard, leopardess,leopardesses, leopards, leotard, leotarded, leotards])


guessesForWordRange:

Optional([Leo, lei, lek, lea, led, lee, leg, let, leu, lev, lex, lao, loo, geo, cleo, oleo, lego, leto, leon])


After it I've implemented the same code for ru_RU

let textChecker = UITextChecker()
let partial = "кош"
let completions = textChecker.completionsForPartialWordRange(NSRange(0..<partial.utf16.count), inString: partial,language: "ru_RU")
let completions2 = textChecker.guessesForWordRange(NSRange(0..<partial.utf16.count), inString: partial, language: "ru_RU")
print(completions)
print(completions2)


But
completionsForPartialWordRange
always returns empty array for
ru_RU
:

Optional([])


Actual result for
"кош"
should be at least
"кошка"
but there is an empty array.

Despite this guessesForWordRange works fine for
ru_RU
:

Optional([каш, ко, кол, коб, код, кое, кож, коз, кои, кой, кок, ком, кон, коп, кор, кос, кот, коф, кою, куш, кэш, нош, шок, ковш, коуш, коша, коше, коши, кошм, кошт, кошу])


I've tried to use different Russian words but I always get empty array from
completionsForPartialWordRange
method.
Do I have a mistake in code or it is some known Apple bug? How to get completions for
ru_RU
with
completionsForPartialWordRange
method?

Answer

If it can help somebody I will provide Apple answer from their bug report service.

After I wrote to Apple I've received the following answer:

Engineering has determined that your bug report is a duplicate of another issue and will be closed.

The open or closed status of the original bug report your issue was duplicated to appears in the yellow "Duplicate of XXXXXXXX" section of the bug reporter user interface. This section appears near the top of the right column's bug detail view just under the bug number, title, state, product and rank.

Unfortunately there were no more additional information.

UPDATE

Fixed in IOS 10.1