List of usage examples for java.util HashMap remove
public V remove(Object key)
From source file:com.jaeksoft.searchlib.crawler.file.process.CrawlFileThread.java
private FileInstanceAbstract[] checkDirectory(FileInstanceAbstract fileInstance) throws SearchLibException, URISyntaxException, IOException { // Load directory from Index HashMap<String, FileInfo> indexFileMap = new HashMap<String, FileInfo>(); fileManager.getFileInfoList(fileInstance.getURI(), indexFileMap); boolean withSubDir = filePathItem.isWithSubDir(); // If the filePathItem does not support subdir if (!withSubDir) for (FileInfo fileInfo : indexFileMap.values()) if (fileInfo.getFileType() == FileTypeEnum.directory) smartDelete(crawlQueue, fileInfo); // Remove existing files from the map FileInstanceAbstract[] files = withSubDir ? fileInstance.listFilesAndDirectories() : fileInstance.listFilesOnly(); if (files != null) for (FileInstanceAbstract file : files) indexFileMap.remove(file.getURI().toASCIIString()); // The file that remain in the map can be removed if (indexFileMap.size() > 0) for (FileInfo fileInfo : indexFileMap.values()) smartDelete(crawlQueue, fileInfo); return files; }
From source file:epsi.i5.datamining.Traitement.java
public void traitement() throws IOException, MalformedURLException, RepustateException, ParseException { StopWords stopword = new StopWords(); boolean bStopWord = false; for (DataEntity entity : builder.getFullCommentaires()) { if (entity.getListeCategorie() == null) { jsonSimpleCat.add(entity.getSimpleCategorie()); jsonListCat = null;/*from ww w . ja va 2 s . co m*/ } else { jsonListCat.add(entity.getListeCategorie()); jsonSimpleCat = null; } String lTrie = ""; if (entity.getSimpleCategorie() == null) { for (String cat : entity.getListeCategorie()) { if (!mapCategorie.containsKey(cat)) { mapCategorie.put(cat, new HashMap<String, Integer>()); } } } else { if (!mapCategorie.containsKey(entity.getSimpleCategorie())) { mapCategorie.put(entity.getSimpleCategorie(), new HashMap<String, Integer>()); } } for (String word : entity.getCommentaires().split(" ")) { //System.out.println(stopword.getRegEx()); for (String stopApo : stopword.getRegExApos().replace("|", " ").split(" ")) { word = word.replaceAll(stopApo, ""); // System.out.println(stopApo); } word = word.replace(".", " ").replace(",", " ").replace("!", " ").replace("(", "").replace(")", "") .replace("'", "").replace(":", "").trim(); for (String stop : stopword.getRegEx().replace("|", " ").split(" ")) { //System.out.println(stop); if ((word.equalsIgnoreCase(stop)) && !word.equalsIgnoreCase("")) { bStopWord = true; } } if (bStopWord == false && !"".equals(word)) { lTrie = lTrie + " " + word; if (entity.getSimpleCategorie() == null) { //Remplissage de la map for (String cat : entity.getListeCategorie()) { if (mapCategorie.get(cat).containsKey(word)) { Integer occurs = mapCategorie.get(cat).get(word); occurs++; mapCategorie.get(cat).remove(word); mapCategorie.get(cat).put(word, occurs); } else { mapCategorie.get(cat).put(word, 1); } } } else { // if (mapCategorie.get(entity.getSimpleCategorie()).containsKey(word)) { // Integer occurs = mapCategorie.get(entity.getSimpleCategorie()).get(word); // occurs++; // mapCategorie.get(entity.getSimpleCategorie()).remove(word); // mapCategorie.get(entity.getSimpleCategorie()).put(word, occurs); // } else { // mapCategorie.get(entity.getSimpleCategorie()).put(word, 1); // } } if (!words.contains(word)) { words.add(word); } } bStopWord = false; } entity.setCommentaireTrie(lTrie); ListDE.add(entity); // System.out.println(entity.getCommentaires()); // System.out.println(entity.getCommentaireTrie()); } arff.chargementData(ListDE); // for (Map.Entry entry : mapCategorie.entrySet()) { // System.out.println(entry); // } //Recherche de la valeur max de chaque mots for (String word : words) { Integer max = 0; for (Entry entry : mapCategorie.entrySet()) { HashMap mapDonnee = (HashMap) entry.getValue(); if (mapDonnee.containsKey(word)) { if (max < (Integer) mapDonnee.get(word)) { max = (Integer) mapDonnee.get(word); } } } // System.out.println(max); //Suppression des mots si ce n'est pas al valuer max for (Entry entry : mapCategorie.entrySet()) { HashMap mapDonnee = (HashMap) entry.getValue(); if (mapDonnee.get(word) != max) { mapDonnee.remove(word); } entry.setValue(mapDonnee); } } // for (Entry entry : mapCategorie.entrySet()) { // System.out.println(entry); // } List<DataEntity> commentairesFinaux = builder.getSimpleCommentaires(); for (DataEntity commentaire : commentairesFinaux) { List<String> categorie; for (String word : commentaire.getCommentaires().split(" ")) { //System.out.println(stopword.getRegEx()); for (String stopApo : stopword.getRegExApos().replace("|", " ").split(" ")) { word = word.replaceAll(stopApo, ""); // System.out.println(stopApo); } word = word.replace(".", " ").replace(",", " ").replace("!", " ").replace("(", "").replace(")", "") .replace("'", "").replace(":", "").trim(); for (String stop : stopword.getRegEx().replace("|", " ").split(" ")) { //System.out.println(stop); if ((word.equalsIgnoreCase(stop)) && !word.equalsIgnoreCase("")) { bStopWord = true; } } if (bStopWord == false) { for (Entry entry : mapCategorie.entrySet()) { HashMap mapDonnee = (HashMap) entry.getValue(); if (mapDonnee.containsKey(word) && !"".equals(word)) { categorie = commentaire.getListeCategorie(); if (!categorie.contains((String) entry.getKey())) { categorie.add((String) entry.getKey()); } commentaire.setListeCategorie(categorie); } } } bStopWord = false; } findCom.add(commentaire.getListeCategorie()); } calculAllpolarite(); for (int i = 0; i < findCom.size(); i++) { if (jsonListCat == null) { System.out.println("Expected : " + jsonSimpleCat.get(i)); } else { System.out.println("Expected : " + jsonListCat.get(i)); } System.out.println("Found : " + findCom.get(i)); if (jsonListCat == null) { if (findCom.get(i).contains(jsonSimpleCat.get(i))) { System.out.println(true); fiabilite++; } else { System.out.println(false); } } else { if (jsonListCat.get(i).containsAll(findCom.get(i))) { System.out.println(true); fiabilite++; } else { System.out.println(false); } } //System.out.println("Raiting : " + polarites.get(i)); //System.out.println("****************************"); } fiabilite = (fiabilite * 100) / findCom.size(); //System.out.println(fiabilite + "%"); arff.generationArff("Step_One"); }
From source file:com.thesmartweb.swebrank.DataManipulation.java
public HashMap sortHashMapByValuesD(HashMap passedMap) { List mapKeys = new ArrayList(passedMap.keySet()); List mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues);/*from w ww .j a v a2 s . co m*/ Collections.sort(mapKeys); HashMap sortedMap = new HashMap(); Iterator valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Object val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); String comp1 = passedMap.get(key).toString(); String comp2 = val.toString(); if (comp1.equals(comp2)) { passedMap.remove(key); mapKeys.remove(key); sortedMap.put((String) key, (Double) val); break; } } } return sortedMap; }
From source file:org.apache.sysml.hops.cost.CostEstimator.java
private void cleanupMRJobVariableStatistics(Instruction inst, HashMap<String, VarStats> stats) { MRJobInstruction jinst = (MRJobInstruction) inst; //get number of indices byte[] indexes = jinst.getIv_resultIndices(); byte maxIx = -1; for (int i = 0; i < indexes.length; i++) if (maxIx < indexes[i]) maxIx = indexes[i];//w w w . j av a 2s . c om //remove all stats up to max index for (int i = 0; i <= maxIx; i++) { VarStats tmp = stats.remove(String.valueOf(i)); if (tmp != null) tmp._inmem = false; //all MR job outptus on HDFS } }
From source file:org.kuali.kra.protocol.personnel.ProtocolPersonnelServiceImplBase.java
/** * This method is to set the total count for each affiliation type * @param protocolPerson//from w w w. j a v a 2 s .c o m * @param investigatorAffiliation */ protected void updateAffiliationCount(ProtocolPersonBase protocolPerson, HashMap<Integer, Integer> investigatorAffiliation) { Integer totalCountForAffiliation = 0; totalCountForAffiliation = investigatorAffiliation.get(protocolPerson.getAffiliationTypeCode()); if (totalCountForAffiliation == null) { investigatorAffiliation.put(protocolPerson.getAffiliationTypeCode(), 1); } else { investigatorAffiliation.remove(protocolPerson.getAffiliationTypeCode()); investigatorAffiliation.put(protocolPerson.getAffiliationTypeCode(), totalCountForAffiliation++); } }
From source file:gsn.webservice.standard.GSNWebServiceSkeleton.java
private void removeSession(String sid) { ServiceContext serviceContext = MessageContext.getCurrentMessageContext().getServiceContext(); HashMap<String, QuerySession> sessions = (HashMap<String, QuerySession>) serviceContext .getProperty(SESSIONS);/*from w ww . j ava2s. co m*/ // sessions.remove(sid); }
From source file:net.opentsdb.tsd.GraphHandler.java
/** Returns the base path to use for the Gnuplot files. */ private String getGnuplotBasePath(final TSDB tsdb, final HttpQuery query) { final Map<String, List<String>> q = query.getQueryString(); q.remove("ignore"); // Super cheap caching mechanism: hash the query string. final HashMap<String, List<String>> qs = new HashMap<String, List<String>>(q); // But first remove the parameters that don't influence the output. qs.remove("png"); qs.remove("json"); qs.remove("ascii"); return tsdb.getConfig().getDirectoryName("tsd.http.cachedir") + Integer.toHexString(qs.hashCode()); }
From source file:net.mlw.vlh.web.tag.DefaultPagingTag.java
/** * * @param sb//from w w w . ja v a 2 s. c o m * @param itemsPerPageParameters * @throws NoSuchMessageException * @throws JspException * @todo DO IT WIHTOUT JAVASCRIPT! */ protected void renderItemsPerPage(StringBuffer sb, HashMap itemsPerPageParameters) throws NoSuchMessageException, JspException { Locale locale = getLocale(); ValueListInfo valueListInfo = getValueListInfo(); TableInfo tableInfo = getTableInfo(); itemsPerPageParameters.remove(ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId()); itemsPerPageParameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), String.valueOf(valueListInfo.getPagingPage())); if (valueListInfo.isFocusEnabled()) { itemsPerPageParameters.put(ValueListInfo.DO_FOCUS + tableInfo.getId(), valueListInfo.isDoFocusAgain() ? "true" : "false"); if (valueListInfo.getFocusProperty() != null) { itemsPerPageParameters.put(ValueListInfo.FOCUS_PROPERTY + tableInfo.getId(), valueListInfo.getFocusProperty()); } if (valueListInfo.getFocusValue() != null) { itemsPerPageParameters.put(ValueListInfo.FOCUS_VALUE + tableInfo.getId(), valueListInfo.getFocusValue()); } } String propertyName = ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId(); String delim = getMessage("paging.delim", null, "", locale); sb.append(delim); final String stylePrefix = getConfig().getStylePrefix(); final String commonStyle = stylePrefix + ITEMS_PER_PAGE_STYLE + " " + ITEMS_PER_PAGE_STYLE; final String labelStyle = stylePrefix + LABEL_STYLE + " " + LABEL_STYLE; final String inputBoxStyle = stylePrefix + INPUT_BOX_STYLE + " " + INPUT_BOX_STYLE; final String submitButtonStyle = stylePrefix + SUBMIT_BUTTON_STYLE + " " + SUBMIT_BUTTON_STYLE; if (isGenerateItemsPerPageForm()) { sb.append("<form action='#' onsubmit='return false;' class='").append(commonStyle).append("'>"); } sb.append("<table border='0' cellspacing='0' cellpadding='0' class='").append(commonStyle).append("'>"); sb.append("\n <tr class='").append(commonStyle).append("'>"); Map labelAttrs = new HashMap(); labelAttrs.put("class", labelStyle); sb.append("\n <td nowrap='true' class='").append(labelStyle).append("'>"); renderPerPageLabel(sb, labelAttrs, getMessage("paging.itemsPerPage.label", null, locale)); sb.append("</td>"); Map inputBoxAttrs = new HashMap(); inputBoxAttrs.put("id", propertyName); inputBoxAttrs.put("name", propertyName); inputBoxAttrs.put("class", inputBoxStyle); inputBoxAttrs.put("title", getMessage("paging.itemsPerPage.title", null, locale)); inputBoxAttrs.put("value", new Integer(valueListInfo.getPagingNumberPer())); sb.append("\n <td class='").append(inputBoxStyle).append("'>"); renderPerPageInputBox(sb, inputBoxAttrs); sb.append("</td>"); Map submitButtonAttrs = new HashMap(); submitButtonAttrs.put("class", submitButtonStyle); submitButtonAttrs.put("value", getMessage("paging.itemsPerPage.button", null, locale)); submitButtonAttrs.put("onclick", "window.location.href = \"" + tableInfo.getUrl() + getConfig().getLinkEncoder().encode(pageContext, itemsPerPageParameters) + propertyName + "=\" + document.getElementById(\"" + propertyName + "\").value;"); sb.append("\n <td class='").append(submitButtonStyle).append("'>"); renderPerPageSubmitButton(sb, submitButtonAttrs); sb.append("</td>"); sb.append("\n </tr>"); sb.append("\n </table>"); if (isGenerateItemsPerPageForm()) { sb.append("</form>"); } }
From source file:de.gfz_potsdam.datasync.Datasync.java
private void addContainerMembers(String parentdir, Container parent, ArrayList<VersionableResource> children) throws Exception { if (parent == null || children == null) return;//from w w w . ja v a2s.co m HashMap<String, VersionableResource> ids = new HashMap<String, VersionableResource>(); for (VersionableResource child : children) { ids.put(child.getObjid(), child); } //do not add twice if (parent.getStructMap() != null) { for (MemberRef m : parent.getStructMap()) { if (ids.containsKey(m.getObjid())) ids.remove(m.getObjid()); } } if (ids.isEmpty()) return; DateTime r = srv.containerAddMembers(parent, ids.values()); File dir = new File(directory + File.separator + parentdir); App.db.storeMapping(parentdir, parent.getObjid(), dir.lastModified(), r, SyncDB.DIRECTORY); log.log(Level.INFO, "added members : {0}", new Object[] { dir.getAbsoluteFile() }); }
From source file:org.kuali.coeus.propdev.impl.s2s.schedule.S2SPollingTask.java
/** * // w ww . j a v a 2s.c o m * This method sends mail for all submission status records that have changed relative to database * * @param htMails * @throws InvalidAddressException * @throws Exception */ private void sendMail(HashMap<String, Vector<SubmissionData>> htMails) throws InvalidAddressException, MessagingException { if (htMails.isEmpty()) { return; } List<MailInfo> mailList = getMailInfoList(); for (MailInfo mailInfo : mailList) { String dunsNum = mailInfo.getDunsNumber(); Vector<SubmissionData> propList = htMails.get(dunsNum); if (propList == null) { continue; } htMails.remove(dunsNum); MailMessage mailMessage = parseNGetMailAttr(propList, mailInfo); if (mailMessage != null) { mailService.sendMessage(mailMessage); } } if (mailList.size() > 0 && !htMails.isEmpty()) { Iterator<String> it = htMails.keySet().iterator(); while (it.hasNext()) { Vector<SubmissionData> nonDunsPropList = htMails.get(it.next()); MailInfo mailInfo = mailList.get(0); MailMessage mailMessage = parseNGetMailAttr(nonDunsPropList, mailInfo); if (mailMessage != null) { mailService.sendMessage(mailMessage); LOG.debug("Sent mail with default duns to " + mailMessage.getToAddresses() + " Subject as " + mailMessage.getSubject() + " Message as " + mailMessage.getMessage()); } } } }