Skip to content

Commit

Permalink
Add Constant object class
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl committed Jun 24, 2020
1 parent ba21687 commit b102bad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import com.github.pemistahl.lingua.api.Language.UNKNOWN
import com.github.pemistahl.lingua.api.Language.VIETNAMESE
import com.github.pemistahl.lingua.api.Language.YORUBA
import com.github.pemistahl.lingua.internal.Alphabet
import com.github.pemistahl.lingua.internal.Constant.MULTIPLE_WHITESPACE
import com.github.pemistahl.lingua.internal.Constant.NUMBERS
import com.github.pemistahl.lingua.internal.Constant.PUNCTUATION
import com.github.pemistahl.lingua.internal.Ngram
import com.github.pemistahl.lingua.internal.TestDataLanguageModel
import com.github.pemistahl.lingua.internal.TrainingDataLanguageModel
Expand Down Expand Up @@ -416,9 +419,6 @@ class LanguageDetector internal constructor(

internal companion object {
private val NO_LETTER = Regex("^[^\\p{L}]+$")
private val PUNCTUATION = Regex("\\p{P}")
private val NUMBERS = Regex("\\p{N}")
private val MULTIPLE_WHITESPACE = Regex("\\s+")
private val JAPANESE_CHARACTER_SET = try {
Regex("^[\\p{Hiragana}\\p{Katakana}\\p{Han}]+$")
} catch (e: PatternSyntaxException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
package com.github.pemistahl.lingua.api.io

import com.github.pemistahl.lingua.api.Language
import com.github.pemistahl.lingua.internal.Constant.MULTIPLE_WHITESPACE
import com.github.pemistahl.lingua.internal.Constant.NUMBERS
import com.github.pemistahl.lingua.internal.Constant.PUNCTUATION
import com.github.pemistahl.lingua.internal.io.FilesWriter
import java.nio.charset.Charset
import java.nio.file.Files
import java.nio.file.Path

object TestDataFilesWriter : FilesWriter() {

private val PUNCTUATION = Regex("\\p{P}")
private val NUMBERS = Regex("\\p{N}")
private val MULTIPLE_WHITESPACE = Regex("\\s+")

/**
* Creates test data files for accuracy report generation and writes them to a directory.
*
Expand Down
24 changes: 24 additions & 0 deletions src/main/kotlin/com/github/pemistahl/lingua/internal/Constant.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright © 2018-2020 Peter M. Stahl [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.pemistahl.lingua.internal

internal object Constant {

val PUNCTUATION = Regex("\\p{P}")
val NUMBERS = Regex("\\p{N}")
val MULTIPLE_WHITESPACE = Regex("\\s+")
}

0 comments on commit b102bad

Please sign in to comment.