Unify unique identities looking for similar identities.
323298
def __unify_unique_identities(self, uidentities, matcher,
                                  fast_matching, interactive):
        """"""

        self.total = len(uidentities)
        self.matched = 0

        if self.recovery and self.recovery_file.exists():
            print("Loading matches from recovery file: %s" % self.recovery_file.location())
            matched = self.recovery_file.load_matches()
        else:
            matched = match(uidentities, matcher, fastmode=fast_matching)
            # convert the matched identities to a common JSON format to ease resuming operations
            matched = self.__marshal_matches(matched)

        self.__merge(matched, interactive)

        if self.recovery:
            self.recovery_file.delete()
439179
def uniq(items):
    
    acc = items[:1]
    for item in items[1:]:
        if item not in acc:
            acc += [item]

    return acc
671792
def merge_dupes(self):
        """"""
        for dupe in self.dupe_of:
            if dupe in self.catalog.entries:
                if self.catalog.entries[dupe]._stub:
                    # merge = False to avoid infinite recursion
                    self.catalog.load_entry_from_name(
                        dupe, delete=True, merge=False)
                self.catalog.copy_entry_to_entry(self.catalog.entries[dupe],
                                                 self)
                del self.catalog.entries[dupe]
        self.dupe_of = []
985416
def sameuuid(a: str, b: str) -> bool:
    """"""
    return a and b and a.lower() == b.lower()
863566
def __load_unique_identities(self, uidentities, matcher, match_new,
                                 reset, verbose):
        """"""

        self.new_uids.clear()

        n = 0

        if reset:
            self.__reset_unique_identities()

        self.log("Loading unique identities...")

        for uidentity in uidentities:
            self.log("\n=====", verbose)
            self.log("+ Processing %s" % uidentity.uuid, verbose)

            try:
                stored_uuid = self.__load_unique_identity(uidentity, verbose)
            except LoadError as e:
                self.error("%s Skipping." % str(e))
                self.log("=====", verbose)
                continue

            stored_uuid = self.__load_identities(uidentity.identities, stored_uuid,
                                                 verbose)

            try:
                self.__load_profile(uidentity.profile, stored_uuid, verbose)
            except Exception as e:
                self.error("%s. Loading %s profile. Skipping profile." %
                           (str(e), stored_uuid))

            self.__load_enrollments(uidentity.enrollments, stored_uuid,
                                    verbose)

            if matcher and (not match_new or stored_uuid in self.new_uids):
                stored_uuid = self._merge_on_matching(stored_uuid, matcher,
                                                      verbose)

            self.log("+ %s (old %s) loaded" % (stored_uuid, uidentity.uuid),
                     verbose)
            self.log("=====", verbose)
            n += 1

        self.log("%d/%d unique identities loaded" % (n, len(uidentities)))
1132844
private static String uniquify(String id, Set<String> knownIds) {
		int n = 10;
		String olda = id;
		while (knownIds.contains(id)) {
			id = olda + Integer.toString(n, Character.MAX_RADIX);
			++n;
		}
		return id;
	}
49669
async function mergeSignatures(source, dest, attr, checkFn) {
  source = source[attr];
  if (source) {
    if (!dest[attr].length) {
      dest[attr] = source;
    } else {
      await Promise.all(source.map(async function(sourceSig) {
        if (!sourceSig.isExpired() && (!checkFn || await checkFn(sourceSig)) &&
            !dest[attr].some(function(destSig) {
              return util.equalsUint8Array(destSig.signature, sourceSig.signature);
            })) {
          dest[attr].push(sourceSig);
        }
      }));
    }
  }
}
692245
public QueryAnswers unify(Unifier unifier){
        if (unifier.isEmpty()) return new QueryAnswers(this);
        QueryAnswers unifiedAnswers = new QueryAnswers();
        this.stream()
            .map(unifier::apply)
            .filter(a -> !a.isEmpty())
            .forEach(unifiedAnswers::add);
        return unifiedAnswers;
    }
24694
def get_similar(self, limit=None):
        """"""

        params = self._get_params()
        if limit:
            params["limit"] = limit

        doc = self._request(self.ws_prefix + ".getSimilar", True, params)

        names = _extract_all(doc, "name")
        matches = _extract_all(doc, "match")

        artists = []
        for i in range(0, len(names)):
            artists.append(
                SimilarItem(Artist(names[i], self.network), _number(matches[i]))
            )

        return artists
457628
def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]:
        """"""
        if not identities:
            return set()
        res = self.derived_from(identities[0])
        for id in identities[1:]:
            res &= self.derived_from(id)
        return res
321294
def similarity(self, other):
        """"""
        ratio = SequenceMatcher(a=self.value, b=other.value).ratio()
        similarity = self.Similarity(ratio)
        return similarity
160782
def _combine(self, original, loc, tokens):
        """"""
        combined_tokens = super(CombineNode, self).postParse(original, loc, tokens)
        internal_assert(len(combined_tokens) == 1, "Combine produced multiple tokens", combined_tokens)
        return combined_tokens[0]
177034
def all_unique(keys, axis=semantics.axis_default):
    """"""
    index = as_index(keys, axis)
    return index.groups == index.size
98861
def get_identities(self, item):
        """"""

        item = item['data']

        for field in ["assignee", "reporter", "creator"]:
            if field not in item["fields"]:
                continue
            if item["fields"][field]:
                user = self.get_sh_identity(item["fields"][field])
                yield user

        comments = item.get('comments_data', [])
        for comment in comments:
            if 'author' in comment and comment['author']:
                user = self.get_sh_identity(comment['author'])
                yield user
            if 'updateAuthor' in comment and comment['updateAuthor']:
                user = self.get_sh_identity(comment['updateAuthor'])
                yield user
821694
def unique(seq):
    """"""
    cleaned = []
    for each in seq:
        if each not in cleaned:
            cleaned.append(each)
    return cleaned
1374199
def similarity(self, other):
        """"""
        if self.magnitude == 0 or other.magnitude == 0:
            return 0

        return self.dot(other) / self.magnitude
835898
public boolean containsDuplicateIdentities() {
        List<Identity> checkedIdentities = new LinkedList<>();
        for (Identity i : identities) {
            for (Identity i2 : checkedIdentities) {
                if (i.equals(i2))
                    return true;
            }
            checkedIdentities.add(i);
        }
        return false;
    }