All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.moe.tlaster.twitter.parser.TwitterParser.kt Maven / Gradle / Ivy

The newest version!
package moe.tlaster.twitter.parser

import moe.tlaster.twitter.parser.builder.TreeBuilder
import moe.tlaster.twitter.parser.tokenizer.StringReader
import moe.tlaster.twitter.parser.tokenizer.Tokenizer

class TwitterParser(
    private val enableEmoji: Boolean = false,
    private val enableDomainDetection: Boolean = false,
    private val enableNonAsciiInUrl: Boolean = true,
    private val enableEscapeInUrl: Boolean = false,
    private val validMarkInUserName: List = listOf(),
    private val validMarkInHashTag: List = listOf(),
) {

    fun parse(input: String): List {
        val tokenizer = Tokenizer(
            enableEmoji = enableEmoji,
            enableDomainDetection = enableDomainDetection,
            enableNonAsciiInUrl = enableNonAsciiInUrl,
            enableEscapeInUrl = enableEscapeInUrl,
            validMarkInUserName = validMarkInUserName,
            validMarkInHashTag = validMarkInHashTag,
        )
        val tokenCharacterTypes = tokenizer.parse(StringReader(input))
        return TreeBuilder().build(StringReader(input), tokenCharacterTypes)
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy