Skip to content

Commit

Permalink
revert unrelated changes
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Nov 2, 2024
1 parent d144d42 commit d7d7975
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
39 changes: 14 additions & 25 deletions src/org/omegat/core/segmentation/Segmenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public SRX getSRX() {
* @param paragraph
* the paragraph text
* @param spaces
* list to store information about spaces between sentences (can
* be null)
* list to store information about spaces between sentences (can be null)
* @param brules
* list to store rules that account to breaks (can be null)
* @return list of sentences (String objects)
Expand Down Expand Up @@ -118,13 +117,11 @@ public List<String> segment(Language lang, String paragraph, List<StringBuilder>
}

/**
* Returns pre-sentences (sentences with spaces between), computed by
* breaking paragraph into chunks of text. Also returns the list with "the
* reasons" why the breaks were made, i.e. the list of break rules that
* contributed to each of the breaks made.
* Returns pre-sentences (sentences with spaces between), computed by breaking paragraph into chunks of
* text. Also returns the list with "the reasons" why the breaks were made, i.e. the list of break rules
* that contributed to each of the breaks made.
* <p>
* If glued back together, these strings form the same paragraph text as
* this function was fed.
* If glued back together, these strings form the same paragraph text as this function was fed.
*
* @param paragraph
* the paragraph text
Expand Down Expand Up @@ -247,8 +244,7 @@ static class BreakPosition implements Comparable<BreakPosition> {
}

/**
* Other BreakPosition is "equal to" this one iff it has the same
* position.
* Other BreakPosition is "equal to" this one iff it has the same position.
*/
public boolean equals(Object obj) {
if (obj == null) {
Expand All @@ -270,12 +266,10 @@ public int hashCode() {
/**
* Compares this break position with another.
*
* @return a negative integer if its position is less than the
* another's, zero if they are equal, or a positive integer as
* its position is greater than the another's.
* @return a negative integer if its position is less than the another's, zero if they are equal, or a
* positive integer as its position is greater than the another's.
* @throws ClassCastException
* if the specified object's type prevents it from being
* compared to this Object.
* if the specified object's type prevents it from being compared to this Object.
*/
public int compareTo(BreakPosition that) {
return this.position - that.position;
Expand Down Expand Up @@ -329,15 +323,14 @@ public String glue(Language sourceLang, Language targetLang, List<String> senten
Matcher matcher = LINE_BREAK_OR_TAB_PATTERN.matcher(sp.toString());
if (matcher.find()) {
// If we found line break or tab, trim left spaces.
// Right spaces are left for indentation of the next
// line.
// Right spaces are left for indentation of the next line.
String leftSpaces = matcher.group(1);
if (!leftSpaces.isEmpty()) {
sp.replace(0, leftSpaces.length(), "");
}
} else if ((lastChar != '.')
&& (!PatternConsts.SPACY_REGEX.matcher(rule.getBeforebreak()).matches()
|| !PatternConsts.SPACY_REGEX.matcher(rule.getAfterbreak()).matches())) {
|| !PatternConsts.SPACY_REGEX.matcher(rule.getAfterbreak()).matches())) {
sp.setLength(0);
}
}
Expand All @@ -354,13 +347,10 @@ public String glue(Language sourceLang, Language targetLang, List<String> senten
* Segment source and target entries from TMX when counts are equals.
*/
public void segmentEntries(boolean needResegment, Language sourceLang, String sourceEntry,
Language targetLang, String targetEntry, List<String> sourceSegments,
List<String> targetSegments) {
Language targetLang, String targetEntry, List<String> sourceSegments, List<String> targetSegments) {
if (needResegment) {
List<String> srcSegments = segment(sourceLang, sourceEntry, null, null);
if (targetEntry != null) { // There is no translation for this
// entry, because for instance it's a
// note
if (targetEntry != null) { // There is no translation for this entry, because for instance it's a note
// on an untranslated entry
List<String> tarSegments = segment(targetLang, targetEntry, null, null);

Expand All @@ -371,8 +361,7 @@ public void segmentEntries(boolean needResegment, Language sourceLang, String so
}
}
}
// No need to resegment, or segments counts not equals, or no
// translation
// No need to resegment, or segments counts not equals, or no translation
sourceSegments.add(sourceEntry);
targetSegments.add(targetEntry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public Class<?> getColumnClass(int columnIndex) {
/** Adds a new empty mapping rule. */
public int addRow() {
int rows = srx.getMappingRules().size();
srx.getMappingRules()
.add(new MapRule(OStrings.getString("SEG_NEW_LN_CO"), "LN-CO", new ArrayList<Rule>()));
srx.getMappingRules().add(
new MapRule(OStrings.getString("SEG_NEW_LN_CO"), "LN-CO", new ArrayList<Rule>()));
fireTableRowsInserted(rows, rows);
return rows;
}
Expand Down

0 comments on commit d7d7975

Please sign in to comment.