List of usage examples for java.util HashSet size
public int size()
From source file:org.runnerup.export.SyncManager.java
public void loadWorkouts(final HashSet<WorkoutRef> pendingWorkouts, final Callback callback) { int cnt = pendingWorkouts.size(); mSpinner.setTitle("Downloading workouts (" + cnt + ")"); mSpinner.show();/*from w w w. ja va 2s . co m*/ new AsyncTask<String, String, Synchronizer.Status>() { @Override protected void onProgressUpdate(String... values) { mSpinner.setMessage("Loading " + values[0] + " from " + values[1]); } @Override protected Synchronizer.Status doInBackground(String... params0) { for (WorkoutRef ref : pendingWorkouts) { publishProgress(ref.workoutName, ref.synchronizer); Synchronizer synchronizer = synchronizers.get(ref.synchronizer); File f = WorkoutSerializer.getFile(mContext, ref.workoutName); File w = f; if (f.exists()) { w = WorkoutSerializer.getFile(mContext, ref.workoutName + ".tmp"); } try { synchronizer.downloadWorkout(w, ref.workoutKey); if (w != f) { if (compareFiles(w, f) != true) { Log.e(getClass().getName(), "overwriting " + f.getPath() + " with " + w.getPath()); // TODO dialog f.delete(); w.renameTo(f); } else { Log.e(getClass().getName(), "file identical...deleting temporary " + w.getPath()); w.delete(); } } } catch (Exception e) { e.printStackTrace(); w.delete(); } } return Synchronizer.Status.OK; } @Override protected void onPostExecute(Synchronizer.Status result) { mSpinner.dismiss(); if (callback != null) { callback.run(null, Synchronizer.Status.OK); } } }.execute("string"); }
From source file:nl.hnogames.domoticz.Preference.Preference.java
private void setPreferences() { final android.preference.SwitchPreference MultiServerPreference = (android.preference.SwitchPreference) findPreference( "enableMultiServers"); android.preference.Preference ServerSettings = findPreference("server_settings"); android.preference.Preference PermissionsSettings = findPreference("permissionssettings"); android.preference.Preference NotificationLogged = findPreference("notification_show_logs"); android.preference.Preference fetchServerConfig = findPreference("server_force_fetch_config"); android.preference.Preference resetApplication = findPreference("reset_settings"); android.preference.ListPreference displayLanguage = (ListPreference) findPreference("displayLanguage"); final android.preference.Preference registrationId = findPreference("notification_registration_id"); android.preference.Preference GeoSettings = findPreference("geo_settings"); android.preference.SwitchPreference WearPreference = (android.preference.SwitchPreference) findPreference( "enableWearItems"); android.preference.Preference NFCPreference = findPreference("nfc_settings"); android.preference.Preference QRCodePreference = findPreference("qrcode_settings"); android.preference.Preference SpeechPreference = findPreference("speech_settings"); android.preference.SwitchPreference EnableNFCPreference = (android.preference.SwitchPreference) findPreference( "enableNFC"); android.preference.SwitchPreference EnableQRCodePreference = (android.preference.SwitchPreference) findPreference( "enableQRCode"); android.preference.SwitchPreference EnableSpeechPreference = (android.preference.SwitchPreference) findPreference( "enableSpeech"); android.preference.SwitchPreference EnableTalkBackPreference = (android.preference.SwitchPreference) findPreference( "talkBack"); MultiSelectListPreference drawerItems = (MultiSelectListPreference) findPreference("enable_menu_items"); @SuppressWarnings("SpellCheckingInspection") android.preference.SwitchPreference AlwaysOnPreference = (android.preference.SwitchPreference) findPreference( "alwayson"); @SuppressWarnings("SpellCheckingInspection") android.preference.PreferenceScreen preferenceScreen = (android.preference.PreferenceScreen) findPreference( "settingsscreen"); android.preference.PreferenceCategory premiumCategory = (android.preference.PreferenceCategory) findPreference( "premium_category"); android.preference.Preference premiumPreference = findPreference("premium_settings"); NotificationsMultiSelectListPreference notificationsMultiSelectListPreference = (NotificationsMultiSelectListPreference) findPreference( "suppressNotifications"); NotificationsMultiSelectListPreference alarmMultiSelectListPreference = (NotificationsMultiSelectListPreference) findPreference( "alarmNotifications"); android.preference.SwitchPreference ThemePreference = (android.preference.SwitchPreference) findPreference( "darkTheme"); android.preference.Preference FingerPrintSettingsPreference = findPreference("SecuritySettings"); android.preference.SwitchPreference FingerPrintPreference = (android.preference.SwitchPreference) findPreference( "enableSecurity"); if (!BuildConfig.DEBUG) { PreferenceCategory oAndroidAutoCategory = (android.preference.PreferenceCategory) findPreference( "androidautocategory"); PreferenceScreen oNotificationScreen = (android.preference.PreferenceScreen) findPreference( "notificationscreen"); oNotificationScreen.removePreference(oAndroidAutoCategory); }//from w w w. j ava 2 s .c o m List<String> notifications = mSharedPrefs.getReceivedNotifications(); if (notifications == null || notifications.size() <= 0) { notificationsMultiSelectListPreference.setEnabled(false); alarmMultiSelectListPreference.setEnabled(false); } else { notificationsMultiSelectListPreference.setEnabled(true); alarmMultiSelectListPreference.setEnabled(true); } PermissionsSettings .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { permissionHelper.openSettingsScreen(); return true; } }); drawerItems.setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { try { final HashSet selectedDrawerItems = (HashSet) newValue; if (selectedDrawerItems.size() < 1) { showSnackbar(mContext.getString(R.string.error_atLeastOneItemInDrawer)); return false; } } catch (Exception ex) { ex.printStackTrace(); return false; } return true; } }); ThemePreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_theme)); return false; } else { ((SettingsActivity) getActivity()).reloadSettings(); return true; } } }); MultiServerPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.multi_server)); return false; } return true; } }); ServerSettings.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (!MultiServerPreference.isChecked()) { Intent intent = new Intent(mContext, ServerSettingsActivity.class); startActivity(intent); } else { Intent intent = new Intent(mContext, ServerListSettingsActivity.class); startActivity(intent); } return true; } }); FingerPrintSettingsPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { mContext.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); return true; } }); fetchServerConfig .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { UsefulBits.getServerConfigForActiveServer(mContext, true, new ConfigReceiver() { @Override public void onReceiveConfig(ConfigInfo settings) { showSnackbar(mContext.getString(R.string.fetched_server_config_success)); } @Override public void onError(Exception error) { showSnackbar(mContext.getString(R.string.fetched_server_config_failed)); } }, null); return true; } }); displayLanguage .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { showRestartMessage(); return true; } }); registrationId.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!PermissionsUtil.canAccessDeviceState(mContext)) { permissionHelper.request(PermissionsUtil.INITIAL_DEVICE_PERMS); } else { pushGCMRegistrationIds(); } } else { pushGCMRegistrationIds(); } return true; } }); GeoSettings.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.geofence)); return false; } else { Intent intent = new Intent(mContext, GeoSettingsActivity.class); startActivity(intent); return true; } } }); EnableNFCPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_nfc)); return false; } if (NfcAdapter.getDefaultAdapter(mContext) == null) { showSnackbar(mContext.getString(R.string.nfc_not_supported)); return false; } return true; } }); EnableQRCodePreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_QRCode)); return false; } return true; } }); EnableSpeechPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_Speech)); return false; } return true; } }); EnableTalkBackPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_talk_back)); return false; } return true; } }); NFCPreference.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_nfc)); return false; } else { Intent intent = new Intent(mContext, NFCSettingsActivity.class); startActivity(intent); return true; } } }); QRCodePreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_QRCode)); return false; } else { Intent intent = new Intent(mContext, QRCodeSettingsActivity.class); startActivity(intent); return true; } } }); SpeechPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_Speech)); return false; } else { Intent intent = new Intent(mContext, SpeechSettingsActivity.class); startActivity(intent); return true; } } }); WearPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_wear)); return false; } return true; } }); AlwaysOnPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.always_on_title)); return false; } return true; } }); NotificationLogged .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { //show dialog List<String> logs = mSharedPrefs.getLoggedNotifications(); if (logs != null && logs.size() > 0) { Collections.reverse(logs); new MaterialDialog.Builder(mContext) .title(mContext.getString(R.string.notification_show_title)) .items((CharSequence[]) logs.toArray(new String[0])).show(); } else UsefulBits.showSimpleToast(mContext, getString(R.string.notification_show_nothing), Toast.LENGTH_LONG); return true; } }); //noinspection PointlessBooleanExpression if (!BuildConfig.LITE_VERSION) { preferenceScreen.removePreference(premiumCategory); } else { premiumPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { String packageID = mContext.getPackageName() + ".premium"; try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageID))); } catch (android.content.ActivityNotFoundException ignored) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageID))); } return true; } }); } resetApplication .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { new MaterialDialog.Builder(mContext).title(R.string.category_Reset) .content(R.string.are_you_sure).positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @SuppressLint("NewApi") @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)) .clearApplicationUserData(); } }).show(); } else { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); } return true; } }); FingerPrintPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @SuppressLint("NewApi") @Override public boolean onPreferenceChange(android.preference.Preference preference, Object o) { if (mSharedPrefs.isStartupSecurityEnabled()) return true; if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_startup_security)); return false; } else { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { UsefulBits.showSimpleToast(mContext, getString(R.string.fingerprint_not_supported), Toast.LENGTH_LONG); return false; } if (!PermissionsUtil.canAccessFingerprint(mContext)) { permissionHelper.request(PermissionsUtil.INITIAL_FINGERPRINT_PERMS); } else { FingerprintManager fingerprintManager = (FingerprintManager) mContext .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!fingerprintManager.isHardwareDetected()) { return false; } else if (!fingerprintManager.hasEnrolledFingerprints()) { UsefulBits.showSimpleToast(mContext, getString(R.string.fingerprint_not_setup_in_android), Toast.LENGTH_LONG); return false; } else { new MaterialDialog.Builder(mContext) .title(R.string.category_startup_security) .content(R.string.fingerprint_sure).positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { mSharedPrefs.setStartupSecurityEnabled(true); ((SettingsActivity) getActivity()).reloadSettings(); } }).show(); return false; } } } } return false; } }); }
From source file:net.unicon.sakora.impl.csv.CsvCommonHandlerService.java
protected int setCurrentAcademicSessions(String[] sessions) { HashSet<String> currentAcademicSessionEids; if (sessions != null) { currentAcademicSessionEids = new HashSet<String>(sessions.length); for (int i = 0; i < sessions.length; i++) { currentAcademicSessionEids.add(sessions[i]); }/*from w w w . j a v a 2s . com*/ } else { currentAcademicSessionEids = new HashSet<String>(0); } if (currentAcademicSessionEids.isEmpty()) { log.warn( "SakoraCSV has no current academic sessions, this is typically not a valid state, please check your sessions.csv file"); } setCurrentSyncVar(CURRENT_SESSION_EIDS, currentAcademicSessionEids); return currentAcademicSessionEids.size(); }
From source file:it.iit.genomics.cru.structures.bridges.uniprot.UniprotkbUtils.java
/** * * @param genes/*from w ww.jav a 2 s . c o m*/ * @return * @throws BridgesRemoteAccessException */ public MapOfMap<String, MoleculeEntry> getUniprotEntriesFromGenes(Collection<String> genes) throws BridgesRemoteAccessException { String tool = UNIPROT_TOOL; MapOfMap<String, MoleculeEntry> gene2uniprots = new MapOfMap<>(genes); HashSet<String> genes2get = new HashSet<>(); try { for (String gene : genes) { if (cache.containsKey(gene.toUpperCase())) { gene2uniprots.addAll(gene, cache.get(gene.toUpperCase())); } else { genes2get.add(gene); // if size == limit, do query if (genes2get.size() == maxQueries) { String location = UNIPROT_SERVER + tool + "/?" + "query=keyword:181+AND+organism:" + URLEncoder.encode("\"" + taxid + "\"", "UTF-8") + "+AND+(gene:" + URLEncoder.encode(StringUtils.join(genes2get, " OR gene:"), "UTF-8") + ")"; Collection<MoleculeEntry> uniprotEntries = getUniprotEntriesXML(location); for (MoleculeEntry entry : uniprotEntries) { String geneName = entry.getGeneName(); // Only use the first one. Using synomyms may cause // ambiguity. if (geneName != null && gene2uniprots.containsKey(geneName)) { gene2uniprots.add(geneName, entry); } } genes2get.clear(); } } } if (genes2get.isEmpty()) { return gene2uniprots; } String location = UNIPROT_SERVER + tool + "/?" + "query=keyword:181+AND+organism:" + URLEncoder.encode("\"" + taxid + "\"", "UTF-8") + "+AND+(gene:" + URLEncoder.encode(StringUtils.join(genes2get, " OR gene:"), "UTF-8") + ")"; Collection<MoleculeEntry> uniprotEntries = getUniprotEntriesXML(location); for (MoleculeEntry entry : uniprotEntries) { String geneName = entry.getGeneName(); // Only use the first one. Using synomyms may cause ambiguity. if (geneName != null && gene2uniprots.containsKey(geneName)) { gene2uniprots.add(geneName, entry); } } } catch (UnsupportedEncodingException e) { logger.error("cannot get proteins for " + StringUtils.join(genes, ", "), e); } return gene2uniprots; }
From source file:it.iit.genomics.cru.structures.bridges.uniprot.UniprotkbUtils.java
/** * * @param xrefs/*w ww . ja v a2 s .c o m*/ * @param filterTaxid * @return * @throws BridgesRemoteAccessException */ public HashMap<String, MoleculeEntry> getUniprotEntriesFromUniprotAccessions(Collection<String> xrefs, boolean filterTaxid) throws BridgesRemoteAccessException { String tool = UNIPROT_TOOL; // remove xrefs that are not uniprotAcs Collection<String> uniprotAcs = getUniprotAcs(xrefs); HashMap<String, MoleculeEntry> results = new HashMap<>(); HashSet<String> ref2get = new HashSet<>(); try { for (String ref : uniprotAcs) { if (cache.containsKey(ref.toUpperCase())) { results.put(ref, cache.get(ref.toUpperCase()).iterator().next()); } else { ref2get.add(ref); // if size == limit, do query if (ref2get.size() == maxQueries) { String location = UNIPROT_SERVER + tool + "/?" + "query=(accession:" + URLEncoder.encode(StringUtils.join(ref2get, " OR accession:") + "", "UTF-8") + ")"; if (filterTaxid) { location += "+AND+keyword:181+AND+organism:" + URLEncoder.encode("\"" + taxid + "\"", "UTF-8"); } Collection<MoleculeEntry> uniprotEntries = getUniprotEntriesXML(location); for (MoleculeEntry entry : uniprotEntries) { results.put(entry.getUniprotAc(), entry); } ref2get.clear(); } } } if (ref2get.isEmpty()) { return results; } String location = UNIPROT_SERVER + tool + "/?" + "query=(accession:" + URLEncoder.encode(StringUtils.join(ref2get, " OR accession:") + "", "UTF-8") + ")"; if (filterTaxid) { location += "+AND+keyword:181+AND+organism:" + URLEncoder.encode("\"" + taxid + "\"", "UTF-8"); } Collection<MoleculeEntry> uniprotEntries = getUniprotEntriesXML(location); for (MoleculeEntry entry : uniprotEntries) { results.put(entry.getUniprotAc(), entry); } } catch (UnsupportedEncodingException e) { logger.error("cannot get proteins for " + StringUtils.join(xrefs, ", "), e); } return results; }
From source file:org.lockss.config.TdbTitle.java
/** * Return the complete list of unique ISSNs for this title. * //www. j a v a 2 s. co m * @return an array of unique ISSNs for this title */ public String[] getIssns() { HashSet<String> issns = new HashSet<String>(); String issn = getPrintIssn(); if (issn != null) issns.add(issn); issn = getEissn(); if (issn != null) issns.add(issn); issn = getIssnL(); if (issn != null) issns.add(issn); return issns.toArray(new String[issns.size()]); }
From source file:de.dfki.km.perspecting.obie.experiments.RelevanceRatingExperiment.java
@Test public void analyseMeanRatings() throws Exception { String[] paths = new String[] { // "/home/adrian/Dokumente/diss/scoobie/results/dbpedia_en2/relevance_wikipedia_combined.csv"}; // "/home/adrian/Dokumente/diss/scoobie/results/dbpedia_en2/relevance_gutenberg_combined.csv"}; "/home/adrian/Dokumente/diss/scoobie/results/dbpedia_en2/relevance_wikinews_combined.csv" }; // "/home/adrian/Dokumente/diss/scoobie/results/bbc_wildlife/relevance_bbc_nature_combined.csv"}; // "/home/adrian/Dokumente/diss/scoobie/results/bbc_music/relevance_bbc_music_combined.csv" // };/* ww w . j a v a 2 s .co m*/ for (String path : paths) { System.out.println(path); BufferedReader r = new BufferedReader(new FileReader(path)); TObjectDoubleHashMap<String> map = new TObjectDoubleHashMap<String>(); final HashSet<String> docs = new HashSet<String>(); int i = 0; for (String line = r.readLine(); line != null; line = r.readLine()) { String[] row = line.split("\t"); double rel = Double.parseDouble(row[2].replace(",", ".")); map.adjustOrPutValue(row[1], rel, rel); docs.add(row[0]); // if (i < 9) { // System.out.println((i++) + ": " + row[1]); // } } map.transformValues(new TDoubleFunction() { @Override public double execute(double value) { return value / docs.size(); } }); map.forEachEntry(new TObjectDoubleProcedure<String>() { @Override public boolean execute(String a, double b) { a = a.replaceAll("\\[", "").replaceAll("\\]", ""); a = a.replace("0", "AuthorityBasedRating"); a = a.replace("1", "HubBasedRating"); a = a.replace("2", "PageRankBasedRating"); a = a.replace("3", "DegreeBasedRating"); a = a.replace("4", "CapacityBasedRating"); a = a.replace("5", "RandomRating"); a = a.replace("6", "PositionBasedRating"); a = a.replace("7", "TermFrequencyBasedRating"); a = a.replace("8", "InverseDocumentFrequencyBasedRating"); System.out.println(String.format(Locale.US, "%s\t%1.3f", a, b)); return true; } }); System.out.println("-------------------------------------------------------"); } }
From source file:com.clustercontrol.jobmanagement.factory.ModifyJob.java
public Long replaceJobunit(List<JobInfo> oldList, List<JobInfo> newList, String userId) throws JobInvalid, JobMasterNotFound, EntityExistsException, HinemosUnknown, JobMasterDuplicate, InvalidSetting, InvalidRole {/*from w w w .jav a 2s. c om*/ //?ID? String jobunitId = newList.get(0).getJobunitId(); // long start = HinemosTime.currentTimeMillis(); HashSet<JobInfo> delJobs = new HashSet<JobInfo>(oldList); HashSet<JobInfo> newJobs = new HashSet<JobInfo>(newList); delJobs.removeAll(newJobs); long timeJobToDelete = HinemosTime.currentTimeMillis(); m_log.info("Find jobs to delete " + (timeJobToDelete - start) + "ms"); HashSet<JobInfo> addJobs = newJobs; addJobs.removeAll(new HashSet<JobInfo>(oldList)); long timeJobToAdd = HinemosTime.currentTimeMillis(); m_log.info("Find jobs to add " + (timeJobToAdd - timeJobToDelete) + "ms"); m_log.info("oldList=" + oldList.size() + ", newList=" + newList.size() + ", delJobs=" + delJobs.size() + ", addJobs=" + addJobs.size()); JpaTransactionManager jtm = new JpaTransactionManager(); for (JobInfo delJob : delJobs) { JobMstEntity entity = QueryUtil.getJobMstPK(delJob.getJobunitId(), delJob.getId()); deleteJob(entity); } jtm.flush(); long timestamp = HinemosTime.currentTimeMillis(); // ???????? for (JobInfo addJob : addJobs) { int type = addJob.getType(); if (type == JobConstant.TYPE_JOBUNIT) { String jobId = addJob.getId(); String parentJobId = addJob.getParentId(); if (jobunitId.equals(jobId)) { parentJobId = CreateJobSession.TOP_JOB_ID; } createJobMasterData(addJob, jobunitId, parentJobId, userId, timestamp); addJobs.remove(addJob); break; } } for (JobInfo addJob : addJobs) { String jobId = addJob.getId(); String parentJobId = addJob.getParentId(); if (jobunitId.equals(jobId)) { parentJobId = CreateJobSession.TOP_JOB_ID; } createJobMasterData(addJob, jobunitId, parentJobId, userId, timestamp); } // ?? String jobId = newList.get(0).getId(); JobMstEntity entity = QueryUtil.getJobMstPK(jobunitId, jobId); entity.setUpdateDate(timestamp); m_log.info("Left tasks in replaceJobunit " + (HinemosTime.currentTimeMillis() - timeJobToAdd) + "ms"); // ?? return timestamp; }
From source file:com.tamingtext.tagrecommender.TestStackOverflowTagger.java
public void execute() { PrintStream out = null;/*w ww. j av a2s. co m*/ try { OpenObjectIntHashMap<String> tagCounts = new OpenObjectIntHashMap<String>(); OpenObjectIntHashMap<String> tagCorrect = new OpenObjectIntHashMap<String>(); loadTags(tagCounts); StackOverflowStream stream = new StackOverflowStream(); stream.open(inputFile.getAbsolutePath()); out = new PrintStream(new FileOutputStream(outputFile)); int correctTagCount = 0; int postCount = 0; HashSet<String> postTags = new HashSet<String>(); float postPctCorrect; int totalSingleCorrect = 0; int totalHalfCorrect = 0; for (StackOverflowPost post : stream) { correctTagCount = 0; postCount++; postTags.clear(); postTags.addAll(post.getTags()); for (String tag : post.getTags()) { if (tagCounts.containsKey(tag)) { tagCounts.adjustOrPutValue(tag, 1, 1); } } ScoreTag[] tags = client.getTags(post.getTitle() + "\n" + post.getBody(), maxTags); for (ScoreTag tag : tags) { if (postTags.contains(tag.getTag())) { correctTagCount += 1; tagCorrect.adjustOrPutValue(tag.getTag(), 1, 1); } } if (correctTagCount > 0) { totalSingleCorrect += 1; } postPctCorrect = correctTagCount / (float) postTags.size(); if (postPctCorrect >= 0.50f) { totalHalfCorrect += 1; } if ((postCount % 100) == 0) { dumpStats(System.err, postCount, totalSingleCorrect, totalHalfCorrect); } } dumpStats(System.err, postCount, totalSingleCorrect, totalHalfCorrect); dumpStats(out, postCount, totalSingleCorrect, totalHalfCorrect); dumpTags(out, tagCounts, tagCorrect); } catch (Exception ex) { throw (RuntimeException) new RuntimeException().initCause(ex); } finally { if (out != null) { out.close(); } } }
From source file:it.iit.genomics.cru.igb.bundles.mi.business.MIResult.java
public float getScore() { if (score > -1) { return score; }/*from w w w.j a v a 2s . co m*/ HashSet<AAPosition> residuesOnProteins = new HashSet<>(); HashSet<AAPosition> residuesOnContacts = new HashSet<>(); residuesOnProteins.addAll(queryResiduesA); residuesOnProteins.addAll(queryResiduesB); residuesOnContacts.addAll(structureMapper.getInterfaceAAPositionsA()); residuesOnContacts.addAll(structureMapper.getInterfaceAAPositionsB()); if (residuesOnProteins.isEmpty()) { return 0; } float residueScore = ((float) residuesOnContacts.size()) / residuesOnProteins.size(); this.score = residueScore; return residueScore; }