-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
181 additions
and
135 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 47 additions & 53 deletions
100
app/src/main/java/fr/medicapp/medicapp/ai/tokenization/CharChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,57 @@ | ||
package fr.medicapp.medicapp.ai.tokenization | ||
package fr.medicapp.medicapp.tokenization | ||
|
||
/** | ||
* Classe CharChecker pour vérifier les caractères spécifiques. | ||
*/ | ||
object CharChecker { | ||
/** | ||
* Pour juger si c'est un caractère vide ou inconnu. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est invalide, faux sinon. | ||
*/ | ||
fun isInvalid(ch: Char): Boolean { | ||
return ch.code == 0 || ch.code == 0xfffd | ||
} | ||
class CharChecker { | ||
companion object { | ||
/** | ||
* Pour juger si c'est un caractère vide ou inconnu. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est invalide, faux sinon. | ||
*/ | ||
fun isInvalid(ch: Char): Boolean { | ||
return ch.code == 0 || ch.code == 0xfffd | ||
} | ||
|
||
/** | ||
* Pour juger si c'est un caractère de contrôle (exclut l'espace blanc). | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est un caractère de contrôle, faux sinon. | ||
*/ | ||
fun isControl(ch: Char): Boolean { | ||
if (Character.isWhitespace(ch)) { | ||
return false | ||
/** | ||
* Pour juger si c'est un caractère de contrôle (exclut l'espace blanc). | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est un caractère de contrôle, faux sinon. | ||
*/ | ||
fun isControl(ch: Char): Boolean { | ||
if (Character.isWhitespace(ch)) { | ||
return false | ||
} | ||
val type = Character.getType(ch) | ||
return type == Character.CONTROL.toInt() || type == Character.FORMAT.toInt() | ||
} | ||
val type = Character.getType(ch) | ||
return type == Character.CONTROL.toInt() || type == Character.FORMAT.toInt() | ||
} | ||
|
||
/** | ||
* Pour juger si cela peut être considéré comme un espace blanc. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est un espace blanc, faux sinon. | ||
*/ | ||
fun isWhitespace(ch: Char): Boolean { | ||
if (Character.isWhitespace(ch)) { | ||
return true | ||
/** | ||
* Pour juger si cela peut être considéré comme un espace blanc. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est un espace blanc, faux sinon. | ||
*/ | ||
fun isWhitespace(ch: Char): Boolean { | ||
if (Character.isWhitespace(ch)) { | ||
return true | ||
} | ||
val type = Character.getType(ch) | ||
return type == Character.SPACE_SEPARATOR.toInt() || type == Character.LINE_SEPARATOR.toInt() || type == Character.PARAGRAPH_SEPARATOR.toInt() | ||
} | ||
val type = Character.getType(ch) | ||
return type == Character.SPACE_SEPARATOR.toInt() || | ||
type == Character.LINE_SEPARATOR.toInt() || | ||
type == Character.PARAGRAPH_SEPARATOR.toInt() | ||
} | ||
|
||
/** | ||
* Pour juger si c'est une ponctuation. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est une ponctuation, faux sinon. | ||
*/ | ||
fun isPunctuation(ch: Char): Boolean { | ||
val type = Character.getType(ch) | ||
return type == Character.CONNECTOR_PUNCTUATION.toInt() || | ||
type == Character.DASH_PUNCTUATION.toInt() || | ||
type == Character.START_PUNCTUATION.toInt() || | ||
type == Character.END_PUNCTUATION.toInt() || | ||
type == Character.INITIAL_QUOTE_PUNCTUATION.toInt() || | ||
type == Character.FINAL_QUOTE_PUNCTUATION.toInt() || | ||
type == Character.OTHER_PUNCTUATION.toInt() | ||
/** | ||
* Pour juger si c'est une ponctuation. | ||
* | ||
* @param ch Le caractère à vérifier. | ||
* @return Vrai si le caractère est une ponctuation, faux sinon. | ||
*/ | ||
fun isPunctuation(ch: Char): Boolean { | ||
val type = Character.getType(ch) | ||
return type == Character.CONNECTOR_PUNCTUATION.toInt() || type == Character.DASH_PUNCTUATION.toInt() || type == Character.START_PUNCTUATION.toInt() || type == Character.END_PUNCTUATION.toInt() || type == Character.INITIAL_QUOTE_PUNCTUATION.toInt() || type == Character.FINAL_QUOTE_PUNCTUATION.toInt() || type == Character.OTHER_PUNCTUATION.toInt() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.