<commit_before>/**
 * Texts
 * <p>
 * Created by Yii.Guxing on 2017-09-17 0017.
 */
package cn.yiiguxing.plugin.translate.util

import javax.swing.text.AttributeSet
import javax.swing.text.Document
import javax.swing.text.Style
import javax.swing.text.StyledDocument

/**
 * 在指定的偏移量([offset])插入字符串([str])
 *
 * @return 插入后`offset`的位置
 * @see [Document.insertString]
 */
fun Document.insert(offset: Int, str: String, attr: AttributeSet? = null): Int {
    insertString(offset, str, attr)
    return offset + str.length
}

/**
 * 在[Document]的末尾插入字符串([str])
 *
 * @see [Document.insertString]
 */
fun Document.appendString(str: String, attr: AttributeSet? = null) = apply { insertString(length, str, attr) }

/**
 * 清空[Document]内容
 */<commit_msg>Document extensions<commit_after>/**
 * Documents
 * <p>
 * Created by Yii.Guxing on 2017-09-17 0017.
 */
@file:Suppress("unused")

package cn.yiiguxing.plugin.translate.util

import javax.swing.text.AttributeSet
import javax.swing.text.Document
import javax.swing.text.Style
import javax.swing.text.StyledDocument

/**
 * 在指定的偏移量([offset])插入字符串([str])
 *
 * @return 插入后`offset`的位置
 * @see [Document.insertString]
 */
fun Document.insert(offset: Int, str: String, attr: AttributeSet? = null): Int {
    insertString(offset, str, attr)
    return offset + str.length
}

/**
 * 在[Document]的末尾插入字符串([str])
 *
 * @see [Document.insertString]
 */
fun Document.appendString(str: String, attr: AttributeSet? = null) = apply { insertString(length, str, attr) }

/**
 * 清空[Document]内容
 */
{'fraction_non_alphanumeric': 0.15768725361366623, 'fraction_numerical': 0.01576872536136662, 'mean_word_length': 4.439285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2142326', 'n_tokens_mistral': 579, 'n_tokens_neox': 581, 'n_words': 108}