Java Code Examples for edu.stanford.nlp.util.StringUtils#capitalize()
The following examples show how to use
edu.stanford.nlp.util.StringUtils#capitalize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyntheticRules.java From phrasal with GNU General Public License v3.0 | 6 votes |
private static <TK,FV> int srcCompoundCnt(IString srcToken, IString tgtToken, List<DynamicTranslationModel<FV>> tmList) { int srcSize = srcToken.length(); int cnt = 0; // each compound should have at least 4 characters for(int k = 4; k < srcSize - 3 ; ++k) { IString[] preSuffixes = new IString[3]; preSuffixes[0] = new IString(srcToken.subSequence(0, k).toString()); // prefix preSuffixes[1] = new IString(srcToken.subSequence(srcSize - k , srcSize).toString()); // suffix preSuffixes[2] = new IString(StringUtils.capitalize(srcToken.subSequence(srcSize - k, srcSize).toString())); // capitalized suffix int mMax = preSuffixes[1] == preSuffixes[2] ? 2 : 3; for(int m = 0; m < mMax; ++m) { IString src = preSuffixes[m]; if(!srcGarbageCollection(src, tmList)) { cnt += tmList.stream().mapToInt(tm -> tm.getJointLexCount(src, tgtToken)).sum(); } } } return cnt; }
Example 2
Source File: SyntheticRules.java From phrasal with GNU General Public License v3.0 | 6 votes |
private static <TK,FV> int tgtCompoundCnt(IString srcToken, IString tgtToken, List<DynamicTranslationModel<FV>> tmList) { int tgtSize = tgtToken.length(); int cnt = 0; // each compound should have at least 4 characters for(int k = 4; k < tgtSize - 3 ; ++k) { IString[] preSuffixes = new IString[3]; preSuffixes[0] = new IString(tgtToken.subSequence(0, k).toString()); // prefix preSuffixes[1] = new IString(tgtToken.subSequence(tgtSize - k , tgtSize).toString()); // suffix preSuffixes[2] = new IString(StringUtils.capitalize(tgtToken.subSequence(tgtSize - k, tgtSize).toString())); // capitalized suffix int mMax = preSuffixes[1] == preSuffixes[2] ? 2 : 3; for(int m = 0; m < mMax; ++m) { IString tgt = preSuffixes[m]; if(!tgtGarbageCollection(tgt, tmList)) { cnt += tmList.stream().mapToInt(tm -> tm.getJointLexCount(srcToken, tgt)).sum(); } } } return cnt; }