@Test public void test() throws Exception { SetupAuiFirstWord fw = new SetupAuiFirstWord(); System.out.println(fw.tokenizeStr("1tok", "heart")); Assert.assertTrue(fw.tokenizeStr("2tok", "heart attack").getFword().equals("heart")); }
public UmlsAuiFirstWord tokenizeStr(String aui, String str) throws Exception { List<?> list = tokenizer.tokenize(str); Iterator<?> tokenItr = list.iterator(); int tCount = 0; String firstTokenText = ""; StringBuilder tokenizedDesc = new StringBuilder(); String firstTokenStem = ""; StringBuilder stemmedDesc = new StringBuilder(); while (tokenItr.hasNext()) { tCount++; Token t = (Token) tokenItr.next(); if (tCount == 1) { firstTokenText = t.getText(); tokenizedDesc.append(firstTokenText); if (this.lvgCmd != null) { firstTokenStem = stemToken(t); stemmedDesc.append(firstTokenStem); } } else { tokenizedDesc.append(" ").append(t.getText()); if (this.lvgCmd != null && firstTokenStem != null) { String stemmedWord = stemToken(t); stemmedDesc.append(" ").append(stemmedWord); } } } UmlsAuiFirstWord fw = new UmlsAuiFirstWord(); fw.setAui(aui); fw.setFword(firstTokenText.toLowerCase(Locale.ENGLISH)); fw.setTokenizedStr(tokenizedDesc.toString()); if (this.lvgCmd != null) { fw.setFstem(firstTokenStem.toLowerCase(Locale.ENGLISH)); fw.setStemmedStr(stemmedDesc.toString()); } return fw; }
SetupAuiFirstWord { public UmlsAuiFirstWord tokenizeStr(String aui, String str) throws Exception { List<?> list = tokenizer.tokenize(str); Iterator<?> tokenItr = list.iterator(); int tCount = 0; String firstTokenText = ""; StringBuilder tokenizedDesc = new StringBuilder(); String firstTokenStem = ""; StringBuilder stemmedDesc = new StringBuilder(); while (tokenItr.hasNext()) { tCount++; Token t = (Token) tokenItr.next(); if (tCount == 1) { firstTokenText = t.getText(); tokenizedDesc.append(firstTokenText); if (this.lvgCmd != null) { firstTokenStem = stemToken(t); stemmedDesc.append(firstTokenStem); } } else { tokenizedDesc.append(" ").append(t.getText()); if (this.lvgCmd != null && firstTokenStem != null) { String stemmedWord = stemToken(t); stemmedDesc.append(" ").append(stemmedWord); } } } UmlsAuiFirstWord fw = new UmlsAuiFirstWord(); fw.setAui(aui); fw.setFword(firstTokenText.toLowerCase(Locale.ENGLISH)); fw.setTokenizedStr(tokenizedDesc.toString()); if (this.lvgCmd != null) { fw.setFstem(firstTokenStem.toLowerCase(Locale.ENGLISH)); fw.setStemmedStr(stemmedDesc.toString()); } return fw; } }
SetupAuiFirstWord { public UmlsAuiFirstWord tokenizeStr(String aui, String str) throws Exception { List<?> list = tokenizer.tokenize(str); Iterator<?> tokenItr = list.iterator(); int tCount = 0; String firstTokenText = ""; StringBuilder tokenizedDesc = new StringBuilder(); String firstTokenStem = ""; StringBuilder stemmedDesc = new StringBuilder(); while (tokenItr.hasNext()) { tCount++; Token t = (Token) tokenItr.next(); if (tCount == 1) { firstTokenText = t.getText(); tokenizedDesc.append(firstTokenText); if (this.lvgCmd != null) { firstTokenStem = stemToken(t); stemmedDesc.append(firstTokenStem); } } else { tokenizedDesc.append(" ").append(t.getText()); if (this.lvgCmd != null && firstTokenStem != null) { String stemmedWord = stemToken(t); stemmedDesc.append(" ").append(stemmedWord); } } } UmlsAuiFirstWord fw = new UmlsAuiFirstWord(); fw.setAui(aui); fw.setFword(firstTokenText.toLowerCase(Locale.ENGLISH)); fw.setTokenizedStr(tokenizedDesc.toString()); if (this.lvgCmd != null) { fw.setFstem(firstTokenStem.toLowerCase(Locale.ENGLISH)); fw.setStemmedStr(stemmedDesc.toString()); } return fw; } SetupAuiFirstWord(); }
SetupAuiFirstWord { public UmlsAuiFirstWord tokenizeStr(String aui, String str) throws Exception { List<?> list = tokenizer.tokenize(str); Iterator<?> tokenItr = list.iterator(); int tCount = 0; String firstTokenText = ""; StringBuilder tokenizedDesc = new StringBuilder(); String firstTokenStem = ""; StringBuilder stemmedDesc = new StringBuilder(); while (tokenItr.hasNext()) { tCount++; Token t = (Token) tokenItr.next(); if (tCount == 1) { firstTokenText = t.getText(); tokenizedDesc.append(firstTokenText); if (this.lvgCmd != null) { firstTokenStem = stemToken(t); stemmedDesc.append(firstTokenStem); } } else { tokenizedDesc.append(" ").append(t.getText()); if (this.lvgCmd != null && firstTokenStem != null) { String stemmedWord = stemToken(t); stemmedDesc.append(" ").append(stemmedWord); } } } UmlsAuiFirstWord fw = new UmlsAuiFirstWord(); fw.setAui(aui); fw.setFword(firstTokenText.toLowerCase(Locale.ENGLISH)); fw.setTokenizedStr(tokenizedDesc.toString()); if (this.lvgCmd != null) { fw.setFstem(firstTokenStem.toLowerCase(Locale.ENGLISH)); fw.setStemmedStr(stemmedDesc.toString()); } return fw; } SetupAuiFirstWord(); static void main(String[] args); void setupAuiFirstWord(); UmlsAuiFirstWord tokenizeStr(String aui, String str); }
SetupAuiFirstWord { public UmlsAuiFirstWord tokenizeStr(String aui, String str) throws Exception { List<?> list = tokenizer.tokenize(str); Iterator<?> tokenItr = list.iterator(); int tCount = 0; String firstTokenText = ""; StringBuilder tokenizedDesc = new StringBuilder(); String firstTokenStem = ""; StringBuilder stemmedDesc = new StringBuilder(); while (tokenItr.hasNext()) { tCount++; Token t = (Token) tokenItr.next(); if (tCount == 1) { firstTokenText = t.getText(); tokenizedDesc.append(firstTokenText); if (this.lvgCmd != null) { firstTokenStem = stemToken(t); stemmedDesc.append(firstTokenStem); } } else { tokenizedDesc.append(" ").append(t.getText()); if (this.lvgCmd != null && firstTokenStem != null) { String stemmedWord = stemToken(t); stemmedDesc.append(" ").append(stemmedWord); } } } UmlsAuiFirstWord fw = new UmlsAuiFirstWord(); fw.setAui(aui); fw.setFword(firstTokenText.toLowerCase(Locale.ENGLISH)); fw.setTokenizedStr(tokenizedDesc.toString()); if (this.lvgCmd != null) { fw.setFstem(firstTokenStem.toLowerCase(Locale.ENGLISH)); fw.setStemmedStr(stemmedDesc.toString()); } return fw; } SetupAuiFirstWord(); static void main(String[] args); void setupAuiFirstWord(); UmlsAuiFirstWord tokenizeStr(String aui, String str);  }