import json

# case: (verdict, cand, confidence, relation, reason, web)
D = {
"v0003": ("SAME", 1, 80, None, "Estate-named apartment row 90 m away in Kepong; web: estate has ~10 apartment blocks, exact block unconfirmed", True),
"v0007": ("PART_OF", 3, 80, "C_in_R", "R is whole Rumah Pangsa Mutiara Indah scheme; C rows are its Fasa/Blok, 36-105 m, standard RM42k", False),
"v0011": ("SAME", 0, 92, None, "Residensi Wangsa 9 = Wangsa 9 Residency, Wangsa Maju in Mukim Setapak; price agrees", False),
"v0015": ("SAME", 0, 90, None, "Web: only Casa Residency in KL is Jalan Pudu serviced residence (2012); median price agrees", True),
"v0019": ("PART_OF", 1, 72, "R_in_C", "R is flats inside Bandar Tasik Selatan township; k1 is township row; too pricey for low-cost row", False),
"v0023": ("PART_OF", 2, 75, "C_in_R", "Web: Ratu Mutiara scheme = Marina Tower plus Twin Towers; C row is Marina Tower", True),
"v0027": ("SAME", 0, 90, None, "Exact distinctive name, Dengkil; median price agrees; C psf copied from Kita Ria row", False),
"v0031": ("UNSURE", 3, 45, None, "R has no location; several Taman Pandan (Penang, JB); two Butterworth buildings both plausible", False),
"v0035": ("PART_OF", 0, 68, "R_in_C", "R is condos within Taman Sutera Utama; C row is the terrace township itself", False),
"v0039": ("SAME", 0, 80, None, "Same estate in Ampang; mixed flat/terrace C row, median price close", False),
"v0043": ("SAME", 0, 90, None, "Exact PPR name, Pantai Dalam in Mukim KL; standard PPR price; Sri Pantai is another PPR", False),
"v0047": ("SAME", 0, 78, None, "Web: Mayang Court is 40-unit condo at Jalan Mayang KLCC; R psf far above PJ namesake", True),
"v0051": ("SAME", 3, 95, None, "Bracketed sub-project Sutera Pines in Bandar Sungai Long; psf and price match", False),
"v0055": ("SAME", 0, 60, None, "Same Taman Bagan estate, Butterworth; estate-level match, flat prices conflict with C median", False),
"v0059": ("SAME", 1, 92, None, "De Bayu Apartment @ Setia Alam, Mukim Bukit Raja; psf and price match", False),
"v0063": ("SAME", 0, 90, None, "Web: Prima Setapak Kondominium (phase I, Jalan Genting Klang); 63 m; phase 2 is elsewhere", True),
"v0067": ("SAME", 1, 92, None, "Flats of Taman Selayang Sejati = Pangsapuri Selayang Sejati; psf and price match", False),
"v0071": ("SAME", 0, 95, None, "Exact name Pangsapuri Mawar, Taman Bukit Serdang; 28 m, Seri Kembangan", False),
"v0075": ("SAME", 3, 95, None, "Bracketed Residensi Alstonia = Alstonia Residence, Bandar Sungai Long; psf and price match", False),
"v0079": ("SAME", 1, 92, None, "Midah Ria flat, Taman Midah Cheras; psf and price match exactly", False),
"v0083": ("SAME", 1, 70, None, "R has no location; Penang Sri Impian fits price best; Seri Kembangan namesake also close", False),
"v0087": ("SAME", 0, 95, None, "231 TR serviced suites, Jalan Tun Razak; psf and price match", False),
"v0091": ("SAME", 0, 82, None, "Web: Senibong Cove had no high-rise; R is its strata homes, psf matches exactly", True),
"v0095": ("PART_OF", 0, 78, "R_in_C", "Permai Court is an apartment block inside Taman Puchong Permai; no own C row", False),
"v0099": ("SAME", 1, 94, None, "Pangsapuri Andorra, Taman Sri Muda Shah Alam; price agrees", False),
"v0103": ("SAME", 0, 92, None, "Web: Mulberi Condominium Kepong, 1,051-1,497 sf, ~RM6xxk fits R; C price data wrong", True),
"v0107": ("DIFFERENT", None, 62, None, "Web: R is Sri Putramas II (Royal Domain, 2007); candidates are phases I, III", True),
"v0111": ("SAME", 1, 95, None, "Penhill Perdana, Ayer Itam; psf and price match", False),
"v0115": ("SAME", 0, 85, None, "Pandan Residence(s) serviced apartment, Johor Bahru; no price check, R district missing", False),
"v0119": ("SAME", 1, 90, None, "Web: The Senai Garden is Pangsapuri Impian Senai in Taman Impian Senai; psf matches", True),
"v0123": ("SAME", 0, 70, None, "Exact name 45 m away, but R says Selangor while C is Keramat KL", False),
"v0127": ("SAME", 3, 90, None, "Web: Residensi Lot 8 is also known as O2 Residence, Puchong South/Putra Permai", True),
"v0131": ("SAME", 0, 92, None, "Exact name 11 m away, R in Mukim Setapak; Kuchai Lama row likely mislocated duplicate", False),
"v0135": ("SAME", 0, 90, None, "Exact name Puncak Erskine, 56 m, Timur Laut", False),
"v0139": ("SAME", 1, 93, None, "Cascades Residences Kota Damansara; psf and price match", False),
"v0143": ("PART_OF", 0, 62, "R_in_C", "R is condos in Bukit Seri Serdang Seksyen 10; C row is the landed section", False),
"v0147": ("SAME", 0, 82, None, "Exact distinctive name, 2 m, Penang; C price well above R", False),
"v0151": ("SAME", 0, 70, None, "Road-named flats on Jalan Khoo Teik Ee; psf 1.38 higher than dated C data", False),
"v0155": ("SAME", 0, 93, None, "Titiwangsa Sentral condo, KL; psf matches", False),
"v0159": ("SAME", 0, 90, None, "Saujana Gombak apartments, Batu Caves/Gombak; psf and price match; coordinates off", False),
"v0163": ("PART_OF", 2, 80, "C_in_R", "R is Pangsapuri Permata in Puchong Permai; C lists Puchong Permata 1/2/3 separately", False),
"v0167": ("SAME", 2, 90, None, "Web: USJ One is You One, 2016 freehold serviced residence USJ 1; R psf fits", True),
"v0171": ("SAME", 0, 95, None, "Web: Spring Avenue is Residensi Kuchai Damai, Kuchai Lama; price range fits", True),
"v0175": ("SAME", 0, 75, None, "Exact name 72 m; R prices anomalously high, but no other Ampangpuri", False),
"v0179": ("SAME", 1, 90, None, "Flat of Taman Murai Jaya, 29 m, Penang; price within tolerance", False),
"v0183": ("SAME", 1, 95, None, "Amadesa, Desa Petaling; psf and price match", False),
"v0187": ("SAME", 0, 65, None, "Same Taman Jawi Jaya flats, Sungai Jawi; R prices much higher than C", False),
"v0191": ("SAME", 0, 72, None, "Same estate, Sekinchan; mixed condo/terrace C row so prices differ", False),
"v0195": ("SAME", 0, 88, None, "Only Penang Taman Wangi, 32 m; other namesakes in other states", False),
"v0199": ("SAME", 0, 93, None, "Web: Urban Suites Jelutong psf RM598-1,013, 630-836 sf; fits R", True),
"v0203": ("SAME", 1, 95, None, "Seasons @ Amara Larkin, JB; psf and price match", False),
"v0207": ("SAME", 1, 95, None, "Indah Samudra condominium JB; psf and price match", False),
"v0211": ("SAME", 0, 88, None, "Pangsapuri Suria Avenue Shah Alam; price agrees; R district missing", False),
"v0215": ("SAME", 0, 90, None, "Exact distinctive name, Penang, 216 m", False),
"v0219": ("PART_OF", 2, 88, "C_in_R", "R covers all Taman Lip Sin flats; C row is Blocks 1, 3 & 5; price matches", False),
"v0223": ("SAME", 0, 93, None, "Vista Subang, Ara Damansara; psf and price match; coordinates off", False),
"v0227": ("SAME", 0, 65, None, "Exact PPR name 52 m, but R prices match non-PPR Desa Tun Razak", False),
"v0231": ("SAME", 3, 85, None, "Pangsapuri Mewah Cheras price matches exactly; R point sits near Taman Cheras Mewah", False),
"v0235": ("SAME", 1, 85, None, "One Tebrau Residence serviced apartment JB; prices only roughly agree", False),
"v0239": ("PART_OF", 2, 82, "C_in_R", "Web: Traders Garden and Traders Park are phases of Cheras Traders Square", True),
"v0243": ("SAME", 0, 93, None, "Mutiara Heights Kajang; psf and price match; Penang namesake different", False),
"v0247": ("SAME", 0, 90, None, "Web: Residensi Sky is The Sky @ Tripark, Bukit Mertajam; brickz RM378 psf/RM510k", True),
"v0251": ("SAME", 0, 70, None, "Manor Apartment KL; psf agrees but price and unit size differ", False),
"v0255": ("PART_OF", 1, 88, "C_in_R", "R combines Bukit Dumbar Indah and Permai; C row is Indah; price matches", False),
"v0259": ("SAME", 0, 85, None, "Exact distinctive name, 8 m, Penang; C price higher", False),
"v0263": ("SAME", 2, 95, None, "Web: Bloomsvale is Menara Vista Petaling, Old Klang Road; price matches", True),
"v0267": ("SAME", 0, 75, None, "Same estate, Semenyih; mixed C row so prices differ", False),
"v0271": ("SAME", 0, 90, None, "Taman Relau Jaya flat, 4 m, mukim 13", False),
"v0275": ("SAME", 1, 95, None, "Jasmine Towers, Section 19 PJ; psf and price match", False),
"v0279": ("SAME", 0, 82, None, "Taman Bukit Segar (Cheras/Ampang border); C row price matches flats", False),
"v0283": ("SAME", 3, 94, None, "Star Residences Two KL; psf and price match", False),
"v0287": ("SAME", 0, 90, None, "Ativo Suites, Damansara Avenue, 64 m; C type label wrong", False),
"v0291": ("SAME", 0, 80, None, "Same estate Medan Batu Caves; mixed C row, price close", False),
"v0295": ("SAME", 0, 58, None, "R lacks district; Taman Permata Alma estate likely, flat prices unmatched", False),
"v0299": ("SAME", 0, 72, None, "Taman Pauh estate, Pauh Jaya; C price matches R flats despite terrace label", False),
"v0303": ("SAME", 0, 85, None, "Exact distinctive name 81 m; R at RUMAWIP price, C psf higher", False),
"v0307": ("PART_OF", 3, 62, "C_in_R", "Web: Kelisa Residence is one of several Taman Kelisa Emas apartments R covers", True),
"v0311": ("SAME", 0, 90, None, "Web: Latitud 3 serviced residence near UM (653-853 sf); 13 m away", True),
"v0315": ("SAME", 0, 94, None, "Taman Sri Indah flat Balik Pulau; estate price matches", False),
"v0319": ("SAME", 1, 95, None, "Ixora Heights, mukim 13; psf and price match", False),
"v0323": ("SAME", 0, 85, None, "Villa Setia Damansara; identical prices possibly circular; R location missing", False),
"v0327": ("SAME", 0, 90, None, "Exact name Taman Manek flat, Penang, 9 m", False),
"v0331": ("SAME", 0, 92, None, "Desa Bayan Apartment, Bayan Lepas; psf and price match", False),
"v0335": ("SAME", 1, 93, None, "Koi Prima Puchong; psf and price match, 45 m", False),
"v0339": ("SAME", 3, 93, None, "Bracketed Garden Park in Bandar Sungai Long; psf and price match", False),
"v0343": ("PART_OF", 0, 62, "R_in_C", "R is flats inside Prima Beruntung township; C row is the township", False),
"v0347": ("SAME", 0, 90, None, "Road-named flats Jalan Sahabat, Bukit Bintang, 7 m", False),
"v0351": ("SAME", 0, 92, None, "Havana Beach Residences, Barat Daya, 44 m; sister row prices match", False),
"v0355": ("SAME", 2, 85, None, "Named Batu Maung estate; price matches; R point misplaced near Balik Pulau namesake", False),
"v0359": ("SAME", 0, 85, None, "Exact name The Madge, 30 m; nearby Madge projects differ", False),
"v0363": ("SAME", 0, 70, None, "Low-cost flats of Taman Sungai Besi estate; mixed C row", False),
"v0367": ("SAME", 0, 82, None, "Laman Indah 2 JB, 108 m; both low-cost priced", False),
"v0371": ("SAME", 1, 92, None, "Sri Golden Bay condominium; psf and price match, 24 m", False),
"v0375": ("PART_OF", 0, 75, "R_in_C", "R is condos in Bandar Seri Putra township; C is township row", False),
"v0379": ("SAME", 0, 93, None, "The Peak Condominium Bintulu, 36 m", False),
"v0383": ("SAME", 0, 78, None, "Vista Bangi serviced apartment; R location missing, prices partly differ", False),
"v0387": ("SAME", 0, 90, None, "Serdang Raya Seksyen 3 apartment row; section row prices match R", False),
"v0391": ("SAME", 0, 82, None, "Taman Ampang Utama estate; price matches", False),
"v0395": ("SAME", 1, 92, None, "Vista Bay Condominium alias, Butterworth; psf and price match", False),
"v0399": ("SAME", 1, 92, None, "Taman Medan Penaga Jelutong; psf and price match", False),
"v0403": ("SAME", 0, 78, None, "Desa Mas Gurney; R location missing, prices 1.23x", False),
"v0407": ("SAME", 0, 92, None, "Quill Residences KL, 96 m", False),
"v0411": ("SAME", 0, 90, None, "Emerald Residence Bayan Lepas, 69 m; other namesakes other states", False),
"v0415": ("SAME", 0, 94, None, "Imperial Lexis KL, 27 m", False),
"v0419": ("SAME", 1, 94, None, "HighPark Suites SS6 Kelana Jaya; psf matches", False),
"v0423": ("SAME", 0, 80, None, "Menara Antara Bukit Bintang, 52 m; C price twice R", False),
"v0427": ("SAME", 1, 85, None, "Exact name and price match Cheras Vista Harmoni; Sentul Vista Harmoni Residences differs", False),
"v0431": ("SAME", 0, 92, None, "Tria @ 9 Seputeh; psf matches", False),
"v0435": ("PART_OF", 0, 90, "R_in_C", "Kelana Mahkota condo lies in SS7 Kelana Jaya locality row", False),
"v0439": ("SAME", 1, 94, None, "The Pinnacles (Pinnacle Tower) JB; psf and price match", False),
"v0443": ("SAME", 0, 80, None, "PKNS flats Jalan Raja Muda Musa; C prices dated, 1.36x", False),
"v0447": ("SAME", 0, 94, None, "22 Macalisterz George Town, 23 m", False),
"v0451": ("PART_OF", 1, 88, "C_in_R", "R covers Tijani 2 North and South; C row is North tower", False),
"v0455": ("SAME", 1, 75, None, "Alias Taman Mutiara Indah matches Mutiara Indah Apartment Gelugor; price matches", False),
"v0459": ("SAME", 1, 80, None, "Taman Bukit Indah Ampang estate row; price matches exactly", False),
"v0463": ("SAME", 1, 95, None, "Zeta DeSkye, Jalan Ipoh; psf and price match", False),
"v0467": ("PART_OF", 0, 55, "R_in_C", "R flats in Taman Anggerik Perdana; C row landed; R district missing", False),
"v0471": ("SAME", 0, 70, None, "Taman Alma Ria estate; flat prices below mixed C rows", False),
"v0475": ("SAME", 2, 93, None, "Puncak Hijauan (Hijauan Heights) Kajang/Bangi; psf and price match", False),
"v0479": ("SAME", 0, 85, None, "Puteri Palma IOI Resort City, 112 m; phase 2 separate", False),
"v0483": ("SAME", 1, 85, None, "Flat Minang Ria, Batu 9 Cheras; price close", False),
"v0487": ("SAME", 0, 94, None, "Web: D'Secret Garden is Pangsapuri Kempas Indah, completed 2017; 14 m", True),
"v0491": ("SAME", 0, 90, None, "Taman Bagan Jermal apartment, Butterworth, 109 m", False),
"v0495": ("SAME", 1, 95, None, "Legasi Kampung Baru; psf and price match", False),
"v0499": ("SAME", 1, 75, None, "Web: Kempas Indah Apt is D'Secret Garden; R psf higher, could be phase 2", True),
"v0503": ("PART_OF", 0, 72, "R_in_C", "R is flats in Bandar Perda township; C is township row", False),
"v0507": ("SAME", 0, 85, None, "Taman Putra Impian Kajang; psf and price match; Seri Kembangan namesake differs", False),
"v0511": ("SAME", 0, 65, None, "Road-named flats Lorong Haji Taib; psf 2.2x C, possibly other block", False),
"v0515": ("PART_OF", 1, 60, "R_in_C", "R inside Taman Ungku Tun Aminah; R prices far above the estate's 1983 flats", False),
"v0519": ("SAME", 1, 93, None, "Taman Sri Angsana Relau; psf and price match", False),
"v0523": ("SAME", 1, 85, None, "Web: Maya Bay is Gamuda Cove's first serviced apartment, 550-968 sf; price fits", True),
"v0527": ("SAME", 3, 92, None, "Alias UNA @ Peel = UNA Residence Jalan Peel; price matches", False),
"v0531": ("SAME", 2, 90, None, "Pandan Utama condo; psf and price match", False),
"v0535": ("SAME", 1, 85, None, "Taman Soga flat, Batu Pahat; price partly agrees", False),
"v0539": ("SAME", 0, 62, None, "Two Taman Tun Perak; web: Rawang flats ~RM145 psf, so R fits Cheras", True),
"v0543": ("SAME", 1, 90, None, "Mesra Jaya Butterworth, 24 m; psf and price match", False),
"v0547": ("SAME", 0, 92, None, "Residensi Seruni RUMAWIP = Seruni Residence, Wangsa Maju, 45 m", False),
"v0551": ("SAME", 0, 90, None, "Precious Court Gurney, 271 m", False),
"v0555": ("SAME", 0, 93, None, "Space Residency JB, 59 m", False),
"v0559": ("SAME", 0, 88, None, "1 Petaling condo, Mukim Petaling; no price check", False),
"v0563": ("SAME", 0, 94, None, "Exact name Aston Acacia serviced apartment, 71 m", False),
"v0567": ("PART_OF", 0, 80, "R_in_C", "Pangsapuri Jaya lies in Taman TTDI Jaya; C row is the estate", False),
"v0571": ("SAME", 0, 90, None, "Taman Indah Murni KL; psf and price match", False),
"v0575": ("SAME", 0, 95, None, "St Mary Residence KL; psf and price match", False),
"v0579": ("SAME", 0, 92, None, "St Regis Residences KL, 16 m", False),
"v0583": ("SAME", 0, 82, None, "Bukit Ampang Permai estate row; price close", False),
"v0587": ("SAME", 0, 90, None, "Exact name Miharja Condominium, 133 m", False),
"v0591": ("SAME", 1, 95, None, "Atmosfera Puchong Jaya; psf and price match", False),
"v0595": ("SAME", 0, 85, None, "Royce Residence KLCC, 49 m; R psf lower than C", False),
"v0599": ("SAME", 2, 95, None, "One @ Bukit Ceylon; psf and price match", False),
"v0603": ("SAME", 3, 90, None, "Residensi Lavender = Lavender Residence, Bandar Sungai Long; price 1.2x", False),
"v0607": ("SAME", 1, 92, None, "Danga View apartment JB; price matches", False),
"v0611": ("SAME", 0, 92, None, "Puncak Desa, Kepong, 86 m", False),
"v0615": ("SAME", 1, 85, None, "Gaya @ Melawati, Hulu Kelang, 119 m; sibling row psf conflicts", False),
"v0619": ("SAME", 0, 94, None, "Ehsan Ria Section 12 PJ; psf and price match", False),
"v0623": ("PART_OF", 0, 72, "R_in_C", "R is flats in Bandar Indahpura township; C is township row", False),
"v0627": ("SAME", 2, 85, None, "Sri Duta development covering I and II; price matches", False),
"v0631": ("SAME", 0, 92, None, "Pangsapuri Kasuarina Bandar Botanic, 156 m; psf agrees", False),
"v0635": ("SAME", 1, 94, None, "Sri Impian Condominium KL; psf and price match", False),
"v0639": ("SAME", 0, 94, None, "Gardenview Residence Cyberjaya; psf and price match", False),
"v0643": ("SAME", 0, 92, None, "Platinum Suites (The Face), KL, 94 m", False),
"v0647": ("SAME", 2, 85, None, "Web: brickz lists this exact scheme as The Gardens @ Polo Park semi-Ds", True),
"v0651": ("SAME", 3, 80, None, "Web: Koi Suites sits at Koi Prima Puchong; price agrees", True),
"v0655": ("PART_OF", 2, 55, "R_in_C", "R flats inside Taman Junid Perdana, Muar; C row landed, coordinates far", False),
"v0659": ("SAME", 0, 90, None, "Damai Villa, 28 Logan Penang, 2 m", False),
"v0663": ("SAME", 0, 90, None, "Sky Habitat @ Meldrum Hills, 1 m; C psf from launch pricing", False),
"v0667": ("SAME", 0, 88, None, "Eco Bloom @ Eco Meadows Simpang Ampat; prices partly differ", False),
"v0671": ("SAME", 0, 78, None, "Web: Shaftsbury Residences serviced apartment 463-906 sf; price matches; other blocks exist", True),
"v0675": ("PART_OF", 0, 78, "R_in_C", "R is condos in Bandar Seri Putra township; C is township row", False),
"v0679": ("SAME", 1, 95, None, "Chymes @ Gurney KL; psf and price match", False),
"v0683": ("SAME", 0, 92, None, "M Condominium Larkin JB; psf and price match", False),
"v0687": ("SAME", 0, 92, None, "The Tropika Bukit Jalil, 78 m", False),
"v0691": ("SAME", 1, 70, None, "UDA flats Tanjung Tokong; R location missing, price close", False),
"v0695": ("SAME", 0, 80, None, "Pangsapuri Harmonis in Taman Harmonis Gombak; price matches", False),
"v0699": ("SAME", 0, 92, None, "Makmur Tanah Rata Jaya, Cameron Highlands, 35 m", False),
"v0703": ("SAME", 0, 95, None, "Villa Puteri Condominium KL; psf and price match", False),
"v0707": ("SAME", 1, 94, None, "Taman Cemerlang George Town flats; psf and price match", False),
"v0711": ("PART_OF", 2, 58, "C_in_R", "R named whole taman; its ~RM1.1M prices match phase 2 semi-Ds nearby", False),
"v0715": ("SAME", 3, 85, None, "Permai Villa Puchong Permai, 18 m; C prices dated", False),
"v0719": ("PART_OF", 1, 90, "C_in_R", "R covers Molek Pine 1 & 2; C row is Molek Pine 2, 46 m", False),
"v0723": ("SAME", 0, 90, None, "Tanming Ria = Taman Taming Ria, Balakong/Kajang; psf and price match", False),
"v0727": ("SAME", 0, 93, None, "Banyan Tree Signatures KL; sister row price matches", False),
"v0731": ("SAME", 1, 85, None, "Green Park Residence Selangor, 119 m; no price check", False),
"v0735": ("SAME", 0, 90, None, "Mutiara Perdana Apartment Bayan Lepas; price matches", False),
"v0739": ("SAME", 0, 80, None, "PPR Raya Permai KL, 117 m; R price above C", False),
"v0743": ("SAME", 1, 90, None, "Desa Tun Razak flats; psf and price match", False),
"v0747": ("SAME", 1, 90, None, "Taman Rombas flat Penang, 32 m", False),
"v0751": ("SAME", 1, 90, None, "The Cove Tanjung Bungah; prices identical; JB namesake is landed", False),
"v0755": ("SAME", 2, 85, None, "Alias Santuary Court = Sanctuary Court, Bukit Mertajam", False),
"v0759": ("SAME", 0, 88, None, "Bella Vista Gurney, Penang; other namesake in Selangor", False),
"v0763": ("SAME", 0, 90, None, "Pangsapuri Kamelia (Camellia Park) Butterworth, 107 m", False),
"v0767": ("SAME", 0, 72, None, "Taman Mutiara Bukit Raja estate; flat prices below C", False),
"v0771": ("SAME", 1, 93, None, "Pangsapuri Bukit Segambut; psf and price match", False),
"v0775": ("SAME", 0, 94, None, "Solstice @ Pan'gaea Cyberjaya; psf and price match", False),
}

src = '/var/www/html/peta/storage/app/propertylab-catalogue-match/review/v_hr_03_in.jsonl'
out = '/var/www/html/peta/storage/app/propertylab-catalogue-match/review/v_hr_03_out.jsonl'
cases = [json.loads(l) for l in open(src)]
ids = [c['case'] for c in cases]
assert len(ids) == len(set(ids)) == 194, len(ids)
missing = [i for i in ids if i not in D]
extra = [i for i in D if i not in ids]
assert not missing, missing
assert not extra, extra
lines = []
problems = []
for c in cases:
    v, k, conf, rel, reason, web = D[c['case']]
    ks = [x['k'] for x in c['catalogue_candidates']]
    if k is not None and k not in ks:
        problems.append((c['case'], 'bad k', k, ks))
    if v in ('SAME', 'PART_OF') and k is None:
        problems.append((c['case'], 'needs k'))
    if v == 'DIFFERENT' and k is not None:
        problems.append((c['case'], 'DIFFERENT with k'))
    if v == 'PART_OF' and rel not in ('R_in_C', 'C_in_R'):
        problems.append((c['case'], 'bad rel'))
    if v != 'PART_OF' and rel is not None:
        problems.append((c['case'], 'rel on non PART_OF'))
    if len(reason.split()) > 20:
        problems.append((c['case'], 'reason too long', len(reason.split())))
    lines.append(json.dumps({"case": c['case'], "verdict": v, "cand": k, "confidence_pct": conf,
                             "relation": rel, "reason": reason, "web": web}, ensure_ascii=False))
print('problems:', problems)
if not problems:
    with open(out, 'w') as f:
        f.write('\n'.join(lines) + '\n')
    from collections import Counter
    print(Counter(D[i][0] for i in ids))
    print('>=90:', sum(1 for i in ids if D[i][2] >= 90))
    print('web cases:', sum(1 for i in ids if D[i][5]))
