Added 2 features: word segment and number conversion - #264
Open
yusufcakmakk wants to merge 1 commit into
Open
Conversation
ahmetaa
requested changes
Mar 18, 2021
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class NumberTextConverter { |
Owner
There was a problem hiding this comment.
Add small doc, what it does exactly.
| public class NumberTextConverter { | ||
|
|
||
| private TurkishMorphology morphology; | ||
| private String patternToFind = "(\\s\\d+\\s(buçuk)\\s)|(\\s(bir|iki|üç|dört|beş|altı|yedi|sekiz|dokuz|on|yirmi|otuz|kırk|elli|atmış|altmış|yetmiş|seksen|doksan|yüz|bin|milyon|milyar)\\s(buçuk)\\s)"; |
|
|
||
| public NumberTextConverter(TurkishMorphology morphology) { | ||
| this.morphology = morphology; | ||
| this.halfNumberPatternT2N = Pattern.compile(patternToFind); |
Owner
There was a problem hiding this comment.
Can be static final defined as a class parameter. No need to initialize it here.
|
|
||
| public class NumberTextConverter { | ||
|
|
||
| private TurkishMorphology morphology; |
| this.halfNumberPatternT2N = Pattern.compile(patternToFind); | ||
| } | ||
|
|
||
| public String replaceTextualNumberWithNumerically(String sentence) { |
| String[] split = matchedPart.split(" "); | ||
| String newString = ""; | ||
| if(split.length > 1) { | ||
| Double bucukNumber = 0.0; |
| return resultText; | ||
| } | ||
|
|
||
| private String convertNumberListToNumericalString(String sentence, List<List<String>> numbers){ |
Owner
There was a problem hiding this comment.
This is rather complex, I will check later. If you add some tests, it is fine.
| import zemberek.morphology.TurkishMorphology; | ||
| import zemberek.normalization.NumberTextConverter; | ||
|
|
||
| public class NumberConversion { |
Owner
There was a problem hiding this comment.
In examples, prefer command like names. Like "ConvertNumbers"
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| public class WordSegment { |
Owner
There was a problem hiding this comment.
"SegmentConnectedWords" or such.
| import zemberek.morphology.TurkishMorphology; | ||
| import zemberek.morphology.analysis.WordAnalysis; | ||
|
|
||
| public class WordSegmenter { |
Owner
There was a problem hiding this comment.
Add small doc. To class or public methods. If you add some tests it is fine, I will check algortihm when I have time.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Word segmenter: it uses dfs algorithm to find parts of string. It depends on Lexicon and word generation.
Number conversion: it uses morphology and disambiguation to find POS and detect numeric values for conversion.