Weihe Wendy Guan

12 papers Journal 12
YearRankTypeTitle / Venue / Authors
2024 J jnl
Ann. GIS
Junghwan Kim, Sampath Rapuri, Kevin Wang, Weihe Wendy Guan, Melinda Laituri
2024 J jnl
Int. J. Appl. Earth Obs. Geoinformation
Lingbo Liu, Fahui Wang, Xiaokang Fu, Tobias Kötter, Kevin Sturm, Weihe Wendy Guan, Shuming Bao
2024 J jnl
SoftwareX
Lingbo Liu, Xiaokang Fu, Tobias Kötter, Kevin Sturm, Carsten Haubold, Weihe Wendy Guan, Shuming Bao, Fahui Wang
2022 J jnl
ISPRS Int. J. Geo Inf.
Lingbo Liu, Ru Wang, Weihe Wendy Guan, Shuming Bao, Hanchen Yu, Xiaokang Fu, Hongqiang Liu
2022 J jnl
Ann. GIS
Akhil Kumar, Yogya Kalra, Weihe Wendy Guan, Vansh Tibrewal, Rupali Batta, Andrew Chen
2020 J jnl
Data Inf. Manag.
Tao Hu, Weihe Wendy Guan, Xinyan Zhu, Yuanzheng Shao, Lingbo Liu, Jing Du, Hongqiang Liu, Huan Zhou, Jialei Wang, Bing She, Luyao Zhang, Zhibin Li, Peixiao Wang, Yicheng Tang, Ruizhi Hou, Yun Li, Dexuan Sha, Yifan Yang, Ben Lewis, Devika Kakkar, Shuming Bao
2020 J jnl
Int. J. Digit. Earth
Chaowei Yang, Dexuan Sha, Qian Liu, Yun Li, Hai Lan, Weihe Wendy Guan, Tao Hu, Zhenlong Li, Zhiran Zhang, John Hoot Thompson, Zifu Wang, David W. S. Wong, Shiyang Ruan, Manzhu Yu, Douglas Richardson, Luyao Zhang, Ruizhi Hou, You Zhou, Cheng Zhong, Yifei Tian, Fayez Beaini, Kyla Carte, Colin Flynn, Wei Liu, Dieter Pfoser, Shuming Bao, Mei Li, Haoyuan Zhang, Chunbo Liu, Jie Jiang, Shihong Du, Liang Zhao, Mingyue Lu, Lin Li, Huan Zhou, Andrew Ding
2019 J jnl
ISPRS Int. J. Geo Inf.
Yongming Xu, Benjamin G. Lewis, Weihe Wendy Guan
2016 J jnl
Trans. GIS
Weihe Wendy Guan, Kang Wu, Fei Carnes
2015 J jnl
Trans. GIS
Weihe Wendy Guan, Alenka Poplin, Benjamin G. Lewis
2012 J jnl
Int. J. Appl. Geospat. Res.
Weihe Wendy Guan, Peter K. Bol
2012 J jnl
Ann. GIS
Weihe Wendy Guan, Peter K. Bol, Benjamin G. Lewis, Matthew Bertrand, Merrick Lex Berman, Jeffrey C. Blossom
redb/extractors/decompiler/bninja/similarity/minhashcustom.py
← Index redb/extractors/decompiler/bninja/similarity/minhashcustom.py python
import numpy as np
import mmh3

class MinHashCustom:
    """
    DTO for an actual MinHash
    <minhash>: a binary sequence of packed int8/32 values
    <minhash_int>: the equivalent representation of <minhash> but as list of int8/32
    """

    _HASH_MAX = 0xFFFFFFFF
    _MINHASH_BITS = 32

    def getSignatureEntrySize(self):
        return 1 if self.MINHASH_BITS <= 8 else 4

    def __init__(self, function_addr=None, minhash_bytes=None, minhash_signature=None, minhash_bits=32):
        self.minhash = b""
        self.minhash_int = []
        if minhash_bits:
            self._MINHASH_BITS = minhash_bits
        if minhash_bytes and minhash_signature:
            raise ValueError("Can use only one keyword argument")
        if minhash_bytes:
            if self._MINHASH_BITS <= 8:
                minhash_signature = np.frombuffer(minhash_bytes, dtype=np.uint8)
            else:
                minhash_signature = np.frombuffer(minhash_bytes, dtype=np.uint32)
            self.setMinHash(minhash_signature)
        elif minhash_signature:
            self.setMinHash(minhash_signature)

        self.shingler_composition = {}
        self.function_addr = function_addr

    def hasMinHash(self):
        return len(self.minhash) > 0

    def getMinHash(self):
        return self.minhash

    def getMinHashInt(self):
        return self.minhash_int

    def setMinHash(self, minhash_signature):
        self.minhash_int = [i % 2 ** self._MINHASH_BITS for i in minhash_signature]
        if self._MINHASH_BITS <= 8:
            self.minhash = np.array(self.minhash_int, dtype=np.uint8).tobytes()
        else:
            self.minhash = np.array(self.minhash_int, dtype=np.uint32).tobytes()

    def getComposition(self):
        return self.shingler_composition

    def scoreAgainst(self, other):
        return self.calculateMinHashScore(self.minhash, other.minhash, minhash_bits=self._MINHASH_BITS)

    @staticmethod
    def getHashMax():
        return MinHashCustom._HASH_MAX

    @staticmethod
    def hashData(data, seed) -> int:
        if isinstance(data, (str, bytes, bytearray)):
            return mmh3.hash(data, seed) & MinHashCustom._HASH_MAX
        elif isinstance(data, (list, tuple)):
            to_hash = "|".join(str(elem) for elem in data)
            return mmh3.hash(to_hash, seed) & MinHashCustom._HASH_MAX
        else:
            raise NotImplementedError(
                f"Type not supported for hashData: {type(data).__name__}"
            )

    @staticmethod
    def calculateMinHashScore(first, second, minhash_bits=32):
        if minhash_bits <= 8:
            first_np = np.frombuffer(first, dtype=np.uint8)
            second_np = np.frombuffer(second, dtype=np.uint8)
        else:
            first_np = np.frombuffer(first, dtype=np.uint32)
            second_np = np.frombuffer(second, dtype=np.uint32)
        return 100.0 * sum(first_np == second_np) / len(first_np)

    @staticmethod
    def calculateMinHashIntScore(first, second):
        score = 0
        num_hashes = len(first)
        if num_hashes:
            for index, part in enumerate(first):
                score += 1 if part == second[index] else 0
            return 100.0 * score / num_hashes
        return 0.0

    @property
    def MINHASH_BITS(self):
        return self._MINHASH_BITS