Ioannis Korkontzelos

55 papers A* 1A 1B 5C 1Journal 24Unranked 21
YearRankTypeTitle / Venue / Authors
2025 J jnl
Appl. Artif. Intell.
Joseph Barrowclough, Nonso Nnamoko, Ioannis Korkontzelos
2024 J jnl
Nat. Lang. Process. J.
Nonso Nnamoko, Themis Karaminis, Jack Procter, Joseph Barrowclough, Ioannis Korkontzelos
2024 J jnl
World Wide Web (WWW)
Nikolaos Polatidis, Stelios Kapetanakis, Marcello Trovati, Ioannis Korkontzelos, Yannis Manolopoulos
2023 J jnl
Nat. Lang. Process. J.
Babatunde Onikoyi, Nonso Nnamoko, Ioannis Korkontzelos
2023 J jnl
CoRR
Ricardo Lopes, Vinh-Thong Ta, Ioannis Korkontzelos
2022 J jnl
Softw. Impacts
Nonso Nnamoko, Ioannis Korkontzelos, Joseph Barrowclough, Mark Liptrott
2021 J jnl
Neurocomputing
Isa Inuwa-Dutse, Mark Liptrott, Ioannis Korkontzelos
2021 conf
MedInfo
George Despotou, Ioannis Korkontzelos, Theodoros N. Arvanitis
2021 J jnl
Big Data Res.
Lalit Garg, Sally I. McClean, Maria Barton, Brian Meenan, Ken Fullerton, Georgios Kontonatsios, Marcello Trovati, Ioannis Korkontzelos, Xiaolong Xu, Mohsen Farid
2021 J jnl
Expert Syst. Appl.
Raja Muhammad Suleman, Ioannis Korkontzelos
2021 J jnl
Comput. Methods Programs Biomed.
Nonso Nnamoko, Luis Adrián Cabrera-Diego, Daniel Campbell, George Sanders, Stuart Fairclough, Ioannis Korkontzelos
2020 J jnl
CoRR
Isa Inuwa-Dutse, Ioannis Korkontzelos
2020 J jnl
Knowl. Based Syst.
Luis Adrián Cabrera-Diego, Nik Bessis, Ioannis Korkontzelos
2020 J jnl
Artif. Intell. Medicine
Nonso Nnamoko, Ioannis Korkontzelos
2020 J jnl
CoRR
Isa Inuwa-Dutse, Mark Liptrott, Ioannis Korkontzelos
2020 J jnl
Expert Syst. Appl. X
Georgios Kontonatsios, Sally Spencer, Peter Matthew, Ioannis Korkontzelos
2019 J jnl
Online Soc. Networks Media
Isa Inuwa-Dutse, Mark Liptrott, Ioannis Korkontzelos
2018 J jnl
Neurocomputing
Isa Inuwa-Dutse, Mark Liptrott, Ioannis Korkontzelos
2018 J jnl
CoRR
Isa Inuwa-Dutse, Bello Shehu Bello, Ioannis Korkontzelos
2018 conf
ICIMTH
George Despotou, Ioannis Korkontzelos, Nicholas Matragkas, Eda Bilici, Theodoros N. Arvanitis
2017 conf
STAF Workshops
Alessandra Bagnato, Konstantinos Barmpis, Nik Bessis, Luis Adrián Cabrera-Diego, Juri Di Rocco, Davide Di Ruscio, Tamás Gergely, Scott Hansen, Dimitris S. Kolovos, Philippe Krief, Ioannis Korkontzelos, Stéphane Laurière, Jose Manrique Lopez de la Fuente, Pedro Maló, Richard F. Paige, Diomidis Spinellis, Cedric Thomas, Jurgen J. Vinju
2016 J jnl
J. Biomed. Informatics
Ioannis Korkontzelos, Azadeh Nikfarjam, Matthew Shardlow, Abeed Sarker, Sophia Ananiadou, Graciela Gonzalez-Hernandez
2016 J jnl
J. Assoc. Inf. Sci. Technol.
Tingting Mu, John Yannis Goulermas, Ioannis Korkontzelos, Sophia Ananiadou
2016 B conf
LREC
Ioannis Korkontzelos, Beverley Thomas, Makoto Miwa, Sophia Ananiadou
2016 B conf
LREC
Ioannis Korkontzelos, Paul Thompson, Sophia Ananiadou
2015 conf
OSS4MDE@MoDELS
Dimitrios S. Kolovos, Nicholas Drivalos Matragkas, Ioannis Korkontzelos, Sophia Ananiadou, Richard F. Paige
2015 J jnl
Artif. Intell. Medicine
Ioannis Korkontzelos, Dimitrios Piliouras, Andrew W. Dowsey, Sophia Ananiadou
2015 ch.
Healthcare Data Analytics
Claudiu Mihaila, Riza Theresa Batista-Navarro, Noha Alnazzawi, Georgios Kontonatsios, Ioannis Korkontzelos, Rafal Rak, Paul Thompson, Sophia Ananiadou
2015 conf
STAF Projects Showcase
Bruno Almeida, Sophia Ananiadou, Alessandra Bagnato, Alberto Berreteaga Barbero, Juri Di Rocco, Davide Di Ruscio, Dimitrios S. Kolovos, Ioannis Korkontzelos, Scott Hansen, Pedro Maló, Nikolaos Drivalos, Richard F. Paige, Jurgen J. Vinju
2015 conf
ESEC/SIGSOFT FSE
Davide Di Ruscio, Dimitris S. Kolovos, Ioannis Korkontzelos, Nicholas Drivalos Matragkas, Jurgen J. Vinju
2014 conf
SLSP
Georgios Kontonatsios, Claudiu Mihaila, Ioannis Korkontzelos, Paul Thompson, Sophia Ananiadou
2014 A* conf
EMNLP
Georgios Kontonatsios, Ioannis Korkontzelos, Jun'ichi Tsujii, Sophia Ananiadou
2014 B conf
COLING
Makoto Miwa, Paul Thompson, Ioannis Korkontzelos, Sophia Ananiadou
2014 B conf
LREC
Ioannis Korkontzelos, Sophia Ananiadou
2014 A conf
EACL
Georgios Kontonatsios, Ioannis Korkontzelos, Jun'ichi Tsujii, Sophia Ananiadou
2013 J jnl
BMC Medical Informatics Decis. Mak.
Angelo C. Restificar, Ioannis Korkontzelos, Sophia Ananiadou
2013 conf
ICHI
Dimitrios Piliouras, Ioannis Korkontzelos, Andrew W. Dowsey, Sophia Ananiadou
2013 J jnl
J. Biomed. Semant.
Georgios Kontonatsios, Ioannis Korkontzelos, BalaKrishna Kolluru, Paul Thompson, Sophia Ananiadou
2013 conf
ACL (Conference System Demonstrations)
Georgios Kontonatsios, Paul Thompson, Riza Theresa Batista-Navarro, Claudiu Mihaila, Ioannis Korkontzelos, Sophia Ananiadou
2013 conf
CICLing (1)
Riza Theresa Batista-Navarro, Georgios Kontonatsios, Claudiu Mihaila, Paul Thompson, Rafal Rak, Raheel Nawaz, Ioannis Korkontzelos, Sophia Ananiadou
2013 conf
Digital Heritage (1)
Paul Thompson, Raheel Nawaz, Ioannis Korkontzelos, William J. Black, John McNaught, Sophia Ananiadou
2013 conf
SemEval@NAACL-HLT
Ioannis Korkontzelos, Torsten Zesch, Fabio Massimo Zanzotto, Chris Biemann
2013 conf
LAW@ACL
Claudiu Mihaila, Georgios Kontonatsios, Riza Theresa Batista-Navarro, Paul Thompson, Ioannis Korkontzelos, Sophia Ananiadou
2013 conf
BUCC@ACL
Georgios Kontonatsios, Ioannis Korkontzelos, Sophia Ananiadou, Jun'ichi Tsujii
2012 J jnl
BMC Medical Informatics Decis. Mak.
Ioannis Korkontzelos, Tingting Mu, Sophia Ananiadou
2012 conf
IHI
Ioannis Korkontzelos, Sophia Ananiadou
2012 C conf
NLDB
Georgios Kontonatsios, Ioannis Korkontzelos, Sophia Ananiadou
2011 conf
SWAT4LS
Georgios Kontonatsios, Ioannis Korkontzelos, BalaKrishna Kolluru, Sophia Ananiadou
2011 conf
LaTeCH@ACL
Kalliopi Zervanou, Ioannis Korkontzelos, Antal van den Bosch, Sophia Ananiadou
2010 conf
HLT-NAACL
Ioannis Korkontzelos, Suresh Manandhar
2010 B conf
COLING
Fabio Massimo Zanzotto, Ioannis Korkontzelos, Francesca Fallucchi, Suresh Manandhar
2010
Ioannis Korkontzelos
2010 conf
SemEval@ACL
Ioannis Korkontzelos, Suresh Manandhar
2009 conf
ACL/IJCNLP (2)
Ioannis Korkontzelos, Suresh Manandhar
2008 conf
GoTAL
Ioannis Korkontzelos, Ioannis P. Klapaftis, Suresh Manandhar
tests/unit/test_decompile_similarity.py
← Index tests/unit/test_decompile_similarity.py python
"""Unit tests for similarity modules:
- bninja/similarity/minhashcustom.py
- bninja/similarity/minhasher.py
"""
import numpy as np
import pytest

from redb.extractors.decompiler.bninja.similarity.minhashcustom import MinHashCustom
from redb.extractors.decompiler.bninja.analysis.low_level_normalization import LowLevelNormalization


# ============================================================================
# 2a. MinHashCustom
# ============================================================================

class TestMinHashCustomInit:
    def test_init_empty(self):
        mh = MinHashCustom()
        assert not mh.hasMinHash()
        assert mh.minhash == b""
        assert mh.minhash_int == []

    def test_init_from_signature(self):
        sig = [10, 20, 30, 40]
        mh = MinHashCustom(minhash_signature=sig)
        assert mh.hasMinHash()
        assert mh.minhash_int == sig

    def test_init_from_bytes_uint32(self):
        """Verify round-trip: ints -> bytes -> MinHashCustom -> ints."""
        sig = [100, 200, 300]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        # np.frombuffer returns numpy scalars; setMinHash does % 2**32 which
        # overflows numpy uint32, so verify the raw bytes round-trip instead.
        raw_arr = np.frombuffer(packed, dtype=np.uint32)
        assert list(raw_arr) == sig

    def test_init_from_bytes_uint8(self):
        """Verify round-trip: ints -> bytes -> back."""
        sig = [10, 20, 30]
        packed = np.array(sig, dtype=np.uint8).tobytes()
        raw_arr = np.frombuffer(packed, dtype=np.uint8)
        assert list(raw_arr) == sig

    def test_init_both_raises(self):
        sig = [1, 2, 3]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        with pytest.raises(ValueError, match="only one"):
            MinHashCustom(minhash_bytes=packed, minhash_signature=sig)


class TestMinHashCustomSetGet:
    def test_set_and_get_minhash(self):
        mh = MinHashCustom()
        sig = [5, 10, 15]
        mh.setMinHash(sig)
        raw = mh.getMinHash()
        assert raw == np.array(sig, dtype=np.uint32).tobytes()
        assert mh.getMinHashInt() == sig

    def test_minhash_int_truncation(self):
        mh = MinHashCustom(minhash_bits=8)
        # Values > 256 should be truncated mod 2^8
        mh.setMinHash([300, 500, 256])
        for val in mh.minhash_int:
            assert 0 <= val < 256


class TestMinHashCustomHashData:
    def test_hash_data_string(self):
        result = MinHashCustom.hashData("hello", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_bytes(self):
        result = MinHashCustom.hashData(b"bytes", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_list(self):
        result = MinHashCustom.hashData([1, 2, 3], 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_unsupported_type(self):
        with pytest.raises(NotImplementedError, match="Type not supported"):
            MinHashCustom.hashData(123, 42)

    def test_hash_data_deterministic(self):
        assert MinHashCustom.hashData("test", 7) == MinHashCustom.hashData("test", 7)


class TestMinHashCustomScore:
    def test_score_identical(self):
        sig = [1, 2, 3, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig)
        mh2 = MinHashCustom(minhash_signature=sig)
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score == 100.0

    def test_score_different(self):
        mh1 = MinHashCustom(minhash_signature=[1, 2, 3, 4, 5])
        mh2 = MinHashCustom(minhash_signature=[6, 7, 8, 9, 10])
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score < 100.0

    def test_score_against(self):
        sig1 = [1, 2, 3, 4, 5]
        sig2 = [1, 2, 99, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig1)
        mh2 = MinHashCustom(minhash_signature=sig2)
        instance_score = mh1.scoreAgainst(mh2)
        static_score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert instance_score == static_score


class TestMinHashCustomBitModes:
    def test_8bit_mode(self):
        mh = MinHashCustom(minhash_bits=8)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint8)
        assert list(arr) == [10, 20, 30]

    def test_32bit_mode(self):
        mh = MinHashCustom(minhash_bits=32)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint32)
        assert list(arr) == [10, 20, 30]


# ============================================================================
# 2b. MinHasher
# ============================================================================


class MockILNode:
    """Mock IL node with operation and operands for normalization."""
    def __init__(self, operation, operands=None):
        self.operation = operation
        self.operands = operands or []


class MockLLILBasicBlock:
    """Mock LLIL basic block that yields IL instructions."""
    def __init__(self, instructions):
        self._instructions = instructions

    def __iter__(self):
        return iter(self._instructions)


class MockLLILFunction:
    """Mock LLIL function with basic blocks."""
    def __init__(self, basic_blocks):
        self.basic_blocks = basic_blocks


# Import MinHasher after we know the module can handle the import
from redb.extractors.decompiler.bninja.similarity.minhasher import (
    MinHasher,
    MINHASH_SIGNATURE_LENGTH,
    MINHASH_SIGNATURE_BITS,
)


class TestMinHasherMakeNgrams:
    def setup_method(self):
        # Create a minimal minhasher with a mock LLIL function
        empty_func = MockLLILFunction([])
        self.hasher = MinHasher(seed=42, il_function=empty_func)

    def test_make_ngrams_basic(self):
        result = self.hasher.make_ngrams(["a", "b", "c", "d"], n=3)
        assert result == [("a", "b", "c"), ("b", "c", "d")]

    def test_make_ngrams_short_input(self):
        result = self.hasher.make_ngrams(["a", "b"], n=3)
        assert result == []

    def test_make_ngrams_exact_n(self):
        result = self.hasher.make_ngrams(["a", "b", "c"], n=3)
        assert result == [("a", "b", "c")]


class TestMinHasherCalculate:
    def _make_llil_function(self, num_instructions=10):
        """Create a mock LLIL function with enough instructions."""
        instructions = [
            MockILNode(operation=i % 20) for i in range(num_instructions)
        ]
        bb = MockLLILBasicBlock(instructions)
        return MockLLILFunction([bb])

    def test_calculate_minhash_empty_function(self):
        # Function with < 3 LLIL instructions -> empty list
        func = self._make_llil_function(num_instructions=2)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert result == []

    def test_calculate_minhash_deterministic(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=42, il_function=func)
        h2 = MinHasher(seed=42, il_function=func)
        assert h1.calculateMinHash() == h2.calculateMinHash()

    def test_calculate_minhash_length(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert len(result) == MINHASH_SIGNATURE_LENGTH

    def test_calculate_minhash_value_range(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        for val in result:
            assert 0 <= val < 2 ** MINHASH_SIGNATURE_BITS

    def test_shingle_hash_deterministic(self):
        func = self._make_llil_function(num_instructions=5)
        hasher = MinHasher(seed=42, il_function=func)
        shingle = ([1, 2], [3, 4], [5, 6])
        assert hasher.shingle_hash(shingle, 99) == hasher.shingle_hash(shingle, 99)

    def test_seed_reproducibility(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=1, il_function=func)
        h2 = MinHasher(seed=2, il_function=func)
        r1 = h1.calculateMinHash()
        r2 = h2.calculateMinHash()
        # Different seeds should (very likely) produce different results
        assert r1 != r2