from collections import defaultdict import re KEYWORDS = defaultdict(list) for line in ''' 1900-1947 (L) aerial shot (I, M, N) agriculture (B, I) air (C) air conditioner (H) anarchism (A) animal (Z) animism (A, S) aporia (A) archipelago (A, Z) ascending/descending (A) assimilation (A) authors/writing (G, I, L) balinese painting (P) bateson (P) barbarian (B) becoming-animal (X) body in water (L, W) bondage (B) boundary (B) buffalo (B, P) burial/grave (D) circle (C) colonialism (B, L, P, Q, T) construction (I) contagion (C, E) corruption (C) cosmology (C, M, S) cmp (G, L, T) mpc (G, L, T) mpaja (G, L, T) decay (D) deleuze/guattari (P) deleuzian diagram (P) diagram (A, H) dispersal/disaggregation (D) ecology (E) efficacy (E) emanation of power (S) espionage (G, L, T) evasion (E, Z) family (K) fanaticism (S) fiction (F) fire (V) first contact (X, Y) flight (F) flora/fauna (F) fluidity (F) foreigner (X, Y) forensics (D) forest (B, F, T, Z) friction (F) frontier (F) geography (G) ghost/spirit (G, S) gong (R) guerilla (G, L) heat (H) highland tribe (P) human remains (D) humidity (D, H) hydrology (H) identity (I) imitation (I) india/china (O) india bce (M) indian prisoners (T) inscription (I) intercourse (X) invulnerability (I) irrigation (H, I, P) japanese occupation (L, T) jellyfish (J, Z) kinship/kingship (K) landscape (H) legibility (L) magic/shamans (F, M, W, Y) malacca (U) mandala (M, S) manpower (M) map (M, S, T) metal (R) mobility (M) modern leader (C) modern nepotism (K, Z) money (C) mountain (A, Z) narcotics (N) narration (N) nationalism (N) network (M, S) obedience (S, Y) ocean (O, Q, U) opium (O) opium war (O) oppression (H, Z) orality (O) origin (O, U) outlaw (F) padi (P) peasants (B, P) periphery (P) piracy (A) plateau (P) politics (P) pontianak (V) pollution (J) queen (Q) question (Q) quotation (Q) rain (D, H) ritual (R, W) river (D, H, L, P) royalty (B, C, K, P, Q, S, U, Z) sea (S) shadow puppet (B) shape-shifter (J, L, Z) singapore (U) singapore before 1900 (T) slavery (S, T) society/state (S) soil (D) soul (S) sumatra (U) survey (M, N, T) sweat/labor (H) swidden agriculture (P) tamil tigers (W) tattoo (I) tiger (B, P, T, W) trade (H) transmission (C, G) transmission of ideology (E) underwater (Q) unreadable sign (I, L) utama (U) vagina (V) vampire (V) voice (V) water (A, H, T, W, Z) water kingdom (Q, U) weretiger (W, Z) women (Q) women with white males (Q) xenophilia/xenophopia (X) yielding (Y) zomia (A, J, Z) zoophilia (Z) zombie (Z) '''.strip().split('\n'): m = re.compile('(.*?) \((.*?)\)').findall(line) term = m[0][0] for id in m[0][1].split(','): id = id.strip() KEYWORDS[id].append(term)