fun morpha(text: String, tags: Boolean): String? { if (text.isEmpty()) { return "" } val textParts: Array<String> = whitespace.split(text) val result = StringBuilder() try { for (textPart in textParts) { val morpha = Morpha(StringReader(textPart), tags) if (result.length != 0) { result.append(" ") } result.append(morpha.next()) } } catch (e: Error) { return text } catch (e: IOException) { return text } return result.toString() }
Run the morpha algorithm on the specified string .