Skip to content

Commit b102bad

Browse files
committed
Add Constant object class
1 parent ba21687 commit b102bad

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/main/kotlin/com/github/pemistahl/lingua/api/LanguageDetector.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ import com.github.pemistahl.lingua.api.Language.UNKNOWN
5959
import com.github.pemistahl.lingua.api.Language.VIETNAMESE
6060
import com.github.pemistahl.lingua.api.Language.YORUBA
6161
import com.github.pemistahl.lingua.internal.Alphabet
62+
import com.github.pemistahl.lingua.internal.Constant.MULTIPLE_WHITESPACE
63+
import com.github.pemistahl.lingua.internal.Constant.NUMBERS
64+
import com.github.pemistahl.lingua.internal.Constant.PUNCTUATION
6265
import com.github.pemistahl.lingua.internal.Ngram
6366
import com.github.pemistahl.lingua.internal.TestDataLanguageModel
6467
import com.github.pemistahl.lingua.internal.TrainingDataLanguageModel
@@ -416,9 +419,6 @@ class LanguageDetector internal constructor(
416419

417420
internal companion object {
418421
private val NO_LETTER = Regex("^[^\\p{L}]+$")
419-
private val PUNCTUATION = Regex("\\p{P}")
420-
private val NUMBERS = Regex("\\p{N}")
421-
private val MULTIPLE_WHITESPACE = Regex("\\s+")
422422
private val JAPANESE_CHARACTER_SET = try {
423423
Regex("^[\\p{Hiragana}\\p{Katakana}\\p{Han}]+$")
424424
} catch (e: PatternSyntaxException) {

src/main/kotlin/com/github/pemistahl/lingua/api/io/TestDataFilesWriter.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717
package com.github.pemistahl.lingua.api.io
1818

1919
import com.github.pemistahl.lingua.api.Language
20+
import com.github.pemistahl.lingua.internal.Constant.MULTIPLE_WHITESPACE
21+
import com.github.pemistahl.lingua.internal.Constant.NUMBERS
22+
import com.github.pemistahl.lingua.internal.Constant.PUNCTUATION
2023
import com.github.pemistahl.lingua.internal.io.FilesWriter
2124
import java.nio.charset.Charset
2225
import java.nio.file.Files
2326
import java.nio.file.Path
2427

2528
object TestDataFilesWriter : FilesWriter() {
2629

27-
private val PUNCTUATION = Regex("\\p{P}")
28-
private val NUMBERS = Regex("\\p{N}")
29-
private val MULTIPLE_WHITESPACE = Regex("\\s+")
30-
3130
/**
3231
* Creates test data files for accuracy report generation and writes them to a directory.
3332
*
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright © 2018-2020 Peter M. Stahl pemistahl@gmail.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.github.pemistahl.lingua.internal
18+
19+
internal object Constant {
20+
21+
val PUNCTUATION = Regex("\\p{P}")
22+
val NUMBERS = Regex("\\p{N}")
23+
val MULTIPLE_WHITESPACE = Regex("\\s+")
24+
}

0 commit comments

Comments
 (0)