Triple Edge adalah tipe Edge untuk menyatakan relasi/properti dalam bentuk (Subject, Property, Object).

Desain Mode Ganda

  • Mode dasar (4 word): PropCode 0~62 (Top 63 properti)
  • Mode ekstensi (5 word): PropCode=63 mencakup semua P-ID (penyelarasan semantik 16-bit)

Mode Dasar (4 word = 64 bit)

1st WORD (16 bit)
┌────────────────────┬────────────────────┐
│      Prefix        │     PropCode       │
│      10bit         │       6bit         │
└────────────────────┴────────────────────┘

2nd WORD: Edge TID (16 bit)
3rd WORD: Subject TID (16 bit)
4th WORD: Object TID (16 bit)
FieldBitDeskripsi
Prefix101100 000 001
PropCode60~62: Top 63 properti, 63: mode ekstensi
Edge TID16TID Edge ini
Subject TID16TID subjek Entity/Node
Object TID16TID objek Entity/Node/Quantity

Mode Ekstensi (5 word = 80 bit)

Jika PropCode = 63, word ke-3 berisi P-ID 16-bit.

1st WORD: [Prefix 10bit] + [PropCode=63 6bit]
2nd WORD: Edge TID (16 bit)
3rd WORD: P-ID penyelarasan semantik (16 bit)
4th WORD: Subject TID (16 bit)
5th WORD: Object TID (16 bit)

Top 63 Properti (PropCode 0~62)

Properti dipilih berdasarkan frekuensi penggunaan Wikidata.

Klasifikasi/tipe (Code 0~7)

CodeP-IDPropertiDeskripsi
0P31instance ofInstansi dari
1P279subclass ofSubkelas dari
2P361part ofBagian dari
3P527has partMemiliki bagian
4P1552has qualityKualitas/sifat
5P460same asSama dengan
6P1889different fromBerbeda dari
7P156followed byDiikuti oleh

Spasial/lokasi (Code 8~15)

CodeP-IDPropertiDeskripsi
8P17countryNegara
9P131located inLokasi (wilayah administratif)
10P276locationLokasi (tempat)
11P625coordinateKoordinat
12P30continentBenua
13P36capitalIbu kota
14P150containsBerisi (wilayah)
15P206located next toPerairan berdekatan

Waktu (Code 16~23)

CodeP-IDPropertiDeskripsi
16P569date of birthTanggal lahir
17P570date of deathTanggal wafat
18P571inceptionTanggal pendirian
19P576dissolvedTanggal pembubaran
20P577publication dateTanggal publikasi
21P580start timeWaktu mulai
22P582end timeWaktu selesai
23P585point in timeTitik waktu

Data dasar individu (Code 24~31)

CodeP-IDPropertiDeskripsi
24P19place of birthTempat lahir
25P20place of deathTempat wafat
26P21sex or genderJenis kelamin
27P27citizenshipKewarganegaraan
28P735given nameNama depan
29P734family nameNama keluarga
30P1559name in native languageNama asli
31P742pseudonymNama samaran

Relasi/keanggotaan (Code 32~39)

CodeP-IDPropertiDeskripsi
32P22fatherAyah
33P25motherIbu
34P26spousePasangan
35P40childAnak
36P3373siblingSaudara kandung
37P463member ofAnggota dari
38P108employerPemberi kerja
39P1027conferred byDiberikan oleh (lembaga)

Profesi/aktivitas (Code 40~47)

CodeP-IDPropertiDeskripsi
40P106occupationProfesi
41P39position heldJabatan
42P69educated atPendidikan
43P101field of workBidang kerja
44P1344participant inPartisipasi (peristiwa)
45P166award receivedPenghargaan
46P800notable workKarya utama
47P1412languages spokenBahasa yang digunakan

Media/identifikasi (Code 48~55)

CodeP-IDPropertiDeskripsi
48P18imageGambar
49P154logoLogo
50P41flag imageBendera
51P373Commons categoryWikimedia
52P856official websiteSitus resmi
53P214VIAF IDVIAF
54P227GND IDGND
55P213ISNIISNI

Karya/kreasi (Code 56~62)

CodeP-IDPropertiDeskripsi
56P50authorPenulis
57P57directorSutradara
58P86composerKomposer
59P175performerPemain/penyanyi
60P136genreGenre
61P364original languageBahasa asli
62P123publisherPenerbit

Code 63 dicadangkan sebagai penanda mode ekstensi.

Ringkasan PropCode

┌─────────────────────────────────────────────┐
│  0~7:   Klasifikasi/tipe (P31, P279, ...)  │
│  8~15:  Spasial/lokasi (P17, P131, ...)    │
│  16~23: Waktu (P569, P570, ...)            │
│  24~31: Data individu (P19, P20, ...)      │
│  32~39: Relasi/keanggotaan (P22, P25, ...) │
│  40~47: Profesi/aktivitas (P106, P39, ...) │
│  48~55: Media/identifikasi (P18, P856, ...)│
│  56~62: Karya/kreasi (P50, P57, ...)       │
├─────────────────────────────────────────────┤
│  63: Penanda mode ekstensi                  │
└─────────────────────────────────────────────┘

Contoh

Mode dasar: “Apple adalah perusahaan”

P31 (instance of) → PropCode = 0

Triple Edge:
  1st: [1100 000 001] + [000000]  - Prefix + PropCode 0
  2nd: [TID: 0x0101]              - Edge TID
  3rd: [TID: 0x0010]              - Apple (Subject)
  4th: [TID: 0x0020]              - perusahaan (Object)

Total: 4 word

Mode ekstensi: “Tinggi Menara Eiffel adalah 330 m”

P2048 (height) → di luar Top 63 → mode ekstensi

Triple Edge:
  1st: [1100 000 001] + [111111]  - Prefix + Ext(63)
  2nd: [TID: 0x0102]              - Edge TID
  3rd: [0xA800]                   - penyelarasan semantik P2048
  4th: [TID: 0x0030]              - Menara Eiffel (Subject)
  5th: [TID: 0x0050]              - 330m Quantity (Object)

Total: 5 word

Parsing

def parse_triple_edge(data: bytes) -> dict:
    word1 = int.from_bytes(data[0:2], 'big')

    prefix = word1 >> 6
    assert prefix == 0b1100000001, "Not Triple Edge"

    prop_code = word1 & 0x3F

    if prop_code < 63:
        # Mode dasar (4 word)
        return {
            'mode': 'basic',
            'prop_code': prop_code,
            'edge_tid': int.from_bytes(data[2:4], 'big'),
            'subject_tid': int.from_bytes(data[4:6], 'big'),
            'object_tid': int.from_bytes(data[6:8], 'big'),
            'words': 4
        }
    else:
        # Mode ekstensi (5 word)
        return {
            'mode': 'extended',
            'p_id': int.from_bytes(data[4:6], 'big'),
            'edge_tid': int.from_bytes(data[2:4], 'big'),
            'subject_tid': int.from_bytes(data[6:8], 'big'),
            'object_tid': int.from_bytes(data[8:10], 'big'),
            'words': 5
        }