@Throws(IOException::class) private fun readSentence(aReader: BufferedReader): List<Array<String>>? { val words: MutableList<Array<String>> = ArrayList() var line: String? var beginSentence = true while (aReader.readLine().also { line = it } != null) { if (com.sun.tools.javac.util.StringUtils.isBlank(line)) { beginSentence = true break } if (hasHeader && beginSentence) { beginSentence = false continue } val fields: Array<String> = line.split(columnSeparator.getValue()).toTypedArray() if (!hasEmbeddedNamedEntity && fields.size != 2 + javax.swing.text.html.HTML.Tag.FORM) { throw IOException( java.lang.String.format( "Invalid file format. Line needs to have %d %s-separated fields: [%s]", 2 + javax.swing.text.html.HTML.Tag.FORM, columnSeparator.getName(), line ) ) } else if (hasEmbeddedNamedEntity && fields.size != 3 + javax.swing.text.html.HTML.Tag.FORM) { throw IOException( java.lang.String.format( "Invalid file format. Line needs to have %d %s-separated fields: [%s]", 3 + javax.swing.text.html.HTML.Tag.FORM, columnSeparator.getName(), line ) ) } words.add(fields) } return if (line == null && words.isEmpty()) { null } else { words } }
Read a single sentence .