<｜begin▁of▁sentence｜>### Instruction:
Given the Word Adjacencies graph which can be read from a GML file named adjnoun.gml, can you use the 'em' function in cdlib to perform community detection? And can you generate and print a JSON representation of the detected communities? Assume we want to detect 3 communities.
### Response:
import networkx as nx
from cdlib import algorithms

# Load the graph
G = nx.read_gml('adjnoun.gml')

# Apply the EM community detection algorithm
# Assuming we want to detect 3 communities
communities = algorithms.em(G, k=3)

# Generate a JSON representation of the detected communities
communities_json = communities.to_json()
print(communities_json)
<|EOT|>
