List of usage examples for org.apache.commons.lang StringUtils normalizeSpace
public static String normalizeSpace(String str)
From source file:com.haulmont.cuba.web.gui.components.mainwindow.WebNewWindowButton.java
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(NEW_WINDOW_BUTTON_STYLENAME, "")); }
From source file:de.tudarmstadt.ukp.csniper.ml.TKSVMlightModelWriter.java
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { // create a new instance for each PennTree for (PennTree t : JCasUtil.select(aJCas, PennTree.class)) { Instance<Boolean> instance = new Instance<Boolean>(); instance.add(new Feature("TK_tree", StringUtils.normalizeSpace(t.getPennTree()))); instance.setOutcome(parseBool(DocumentMetaData.get(aJCas).getDocumentTitle())); train(instance);//from ww w .j ava 2 s . com } }
From source file:com.haulmont.cuba.web.gui.components.WebRowsCount.java
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(TABLE_ROWS_COUNT_STYLENAME, "")); }
From source file:com.apexxs.neonblack.detection.CardinalDetector.java
public List<DetectedLocation> extractLocationNames(String text) { if (config.removeStopWords()) { text = textUtilities.cleanStopwords(text); }//from w w w .j a va2 s.c o m text = StringUtils.normalizeSpace(text); Map<String, DetectedLocation> nerResults = new HashMap<>(); RegexDetector regexExtractor = new RegexDetector(); List<DetectedLocation> regexFinds = regexExtractor.extractLocationNames(text); for (DetectedLocation loc : regexFinds) { if (!nerResults.containsKey(loc.name)) { nerResults.put(loc.name, loc); } else { nerResults.get(loc.name).startPos.addAll(loc.startPos); nerResults.get(loc.name).stopPos.addAll(loc.stopPos); } } List<Triple<String, Integer, Integer>> extracts = this.classifier.classifyToCharacterOffsets(text); if (extracts != null) { for (Triple<String, Integer, Integer> extract : extracts) { if (extract.first.equalsIgnoreCase("LOCATION")) { String locText = text.substring(extract.second, extract.third); if (config.removeDemonyms()) { if (textUtilities.isDemonym(locText)) { locText = StringUtils.EMPTY; } } if (!StringUtils.isEmpty(locText)) { if (!nerResults.containsKey(locText.toLowerCase())) { nerResults.put(locText.toLowerCase(), new DetectedLocation(locText, extract.second, extract.third)); } else { nerResults.get(locText.toLowerCase()).startPos.add(extract.second); nerResults.get(locText.toLowerCase()).stopPos.add(extract.third); } } } } } List<DetectedLocation> binnedLocations = new ArrayList<>(nerResults.values()); //List<DetectedLocation> detections = new ArrayList<>(); /*if (config.removeDemonyms()) { CaseInsensitiveList demonyms = textUtilities.getDemonyms(); for (DetectedLocation dloc : binnedLocations) { if (!demonyms.contains(dloc.name)) { detections.add(dloc); } } }*/ if (config.replaceSynonyms()) { for (DetectedLocation dloc : binnedLocations) { String synonym = textUtilities.getSynonym(dloc.name); if (!StringUtils.isEmpty(synonym)) { dloc.synonym = synonym; } } } LocationInspector locationInspector = new LocationInspector(); return (locationInspector.inspectLocations(binnedLocations, text)); //return detections; }
From source file:com.haulmont.cuba.web.gui.components.mainwindow.WebAppMenu.java
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(MENU_STYLENAME, "")); }
From source file:de.tudarmstadt.ukp.csniper.resbuild.stuff.PrintConsumer.java
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { DocumentMetaData meta = DocumentMetaData.get(aJCas); if (meta != null) { System.out.println("DOCUMENT_META_DATA:"); System.out.println("col_id = " + meta.getCollectionId()); System.out.println("doc_base_uri = " + meta.getDocumentBaseUri()); System.out.println("doc_id = " + meta.getDocumentId()); System.out.println("doc_title = " + meta.getDocumentTitle()); System.out.println("doc_uri = " + meta.getDocumentUri()); System.out.println("\n"); }/*from w w w . j a v a2s .c o m*/ // for (Candidate c : JCasUtil.select(aJCas, Candidate.class)) { // System.out.print(StringUtils.leftPad(Integer.toString(c.getBegin()), 6) + "-"); // System.out.print(StringUtils.leftPad(Integer.toString(c.getEnd()), 6) + " "); // System.out.print(StringUtils.normalizeSpace(c.getCoveredText())); // System.out.println(); // } // System.out.println("----"); // // for (Sentence s : JCasUtil.select(aJCas, Sentence.class)) { // System.out.println(follow(s)); // } // System.out.println("----"); for (PennTree p : JCasUtil.select(aJCas, PennTree.class)) { // System.out.println(p.getPennTree()); System.out.println(p.getCoveredText()); System.out.println(StringUtils.normalizeSpace(p.getPennTree()) + "\n"); } System.out.println("----"); // System.out.println(aJCas.getDocumentText()); }
From source file:de.tudarmstadt.ukp.csniper.ml.TKSVMlightComparator.java
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { // create a new instance for each PennTree for (PennTree t : JCasUtil.select(aJCas, PennTree.class)) { HideOutput hide = new HideOutput(); Feature tree = new Feature("TK_tree", StringUtils.normalizeSpace(t.getPennTree())); boolean gold = parseBool(DocumentMetaData.get(aJCas).getDocumentTitle()); boolean clas = classifier.classify(Arrays.asList(tree)); hide.restoreOutput();/*from www. j a va 2s.c o m*/ if (gold == true) { if (clas == true) { tp++; } else { fn++; } } else { if (clas == true) { fp++; } else { tn++; } } } }
From source file:com.tikal.tallerWeb.modelo.servicio.ServicioLoaded.java
@Override public String toString() { String result = ""; if (this.getServicio().getId() == null) { result = StringUtils.join(new String[] { this.auto.getTipo(), this.auto.getColor() }, ' '); result = StringUtils.normalizeSpace(result); if (StringUtils.isEmpty(result)) { result = "Nuevo servicio"; }/*from w ww . j av a2s. c o m*/ } else { result = StringUtils.join( new String[] { this.servicio.getId().toString(), this.auto.getTipo(), this.auto.getColor() }, ' '); result = StringUtils.normalizeSpace(result); } return result; }
From source file:chiliad.parser.pdf.extractor.text.TextExtractor.java
private MToken toMToken(Token token) { MToken mToken = new MToken(); mToken.setText(StringUtils.normalizeSpace(StringUtils.trimToEmpty(token.getText()))); mToken.setFontFamily(token.getFontFamily()); mToken.setFontName(token.getFontName()); mToken.setFontSizeInPt(token.getFontSizeInPt()); mToken.setFontWeight(token.getFontWeight()); mToken.setNonStrokingColor(MToken.colorToRgba(token.getNonStrokingColor())); mToken.setStrokingColor(MToken.colorToRgba(token.getStrokingColor())); mToken.setX(token.getPositionStartX()); mToken.setY(token.getPositionStartY()); mToken.setWidth(token.getWidth());// w w w . j a v a 2s .c om mToken.setHeight(token.getHeight()); return mToken; }
From source file:com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea.java
@Override public String getStyleName() { return StringUtils.normalizeSpace( super.getStyleName().replace(MODE_TABBED_STYLENAME, "").replace(MODE_SINGLE_STYLENAME, "") .replace(STATE_INITIAL_STYLENAME, "").replace(STATE_WINDOWS_STYLENAME, "")); }