<｜begin▁of▁sentence｜>### Instruction:
Given the network of the adjacency of common adjectives and nouns in the novel 'David Copperfield', which can be read from a GML file named 'adjnoun.gml', can you use both the Louvain and Leiden algorithms in cdlib to perform community detection on this graph? And then, can you compute the average F1 score of the optimal matches among the partitions obtained from these algorithms?
### Response:
import networkx as nx
from cdlib import algorithms, evaluation

# Read the graph structure from the adjnoun graph file
G = nx.read_gml('adjnoun.gml')

# Perform community detection using the Louvain algorithm
louvain_communities = algorithms.louvain(G)

# Perform community detection using the Leiden algorithm
leiden_communities = algorithms.leiden(G)

# Compute the average F1 score between the two partitions
f1_score = evaluation.f1(louvain_communities, leiden_communities)

print(f1_score.score)
<|EOT|>
