Update modules/syntax_analysis.py
Browse files
modules/syntax_analysis.py
CHANGED
@@ -83,10 +83,10 @@ POS_TRANSLATIONS = {
|
|
83 |
'X': 'Autre',
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
def count_pos(doc):
|
88 |
return Counter(token.pos_ for token in doc if token.pos_ != 'PUNCT')
|
89 |
-
|
90 |
def create_syntax_graph(doc, lang):
|
91 |
G = nx.DiGraph()
|
92 |
pos_counts = count_pos(doc)
|
@@ -113,7 +113,7 @@ def create_syntax_graph(doc, lang):
|
|
113 |
G.add_edge(head_id, word_nodes[lower_text], label=token.dep_)
|
114 |
|
115 |
return G, word_colors
|
116 |
-
|
117 |
def visualize_syntax_graph(doc, lang):
|
118 |
G, word_colors = create_syntax_graph(doc, lang)
|
119 |
|
@@ -142,7 +142,7 @@ def visualize_syntax_graph(doc, lang):
|
|
142 |
plt.legend(handles=legend_elements, loc='center left', bbox_to_anchor=(1, 0.5), fontsize=12) # Increase legend font size
|
143 |
|
144 |
return plt
|
145 |
-
|
146 |
def visualize_syntax(text, nlp, lang):
|
147 |
max_tokens = 5000
|
148 |
doc = nlp(text)
|
|
|
83 |
'X': 'Autre',
|
84 |
}
|
85 |
}
|
86 |
+
########################################################################################################################################
|
87 |
def count_pos(doc):
|
88 |
return Counter(token.pos_ for token in doc if token.pos_ != 'PUNCT')
|
89 |
+
#######################################################################################################################################
|
90 |
def create_syntax_graph(doc, lang):
|
91 |
G = nx.DiGraph()
|
92 |
pos_counts = count_pos(doc)
|
|
|
113 |
G.add_edge(head_id, word_nodes[lower_text], label=token.dep_)
|
114 |
|
115 |
return G, word_colors
|
116 |
+
####################################################################################################################################
|
117 |
def visualize_syntax_graph(doc, lang):
|
118 |
G, word_colors = create_syntax_graph(doc, lang)
|
119 |
|
|
|
142 |
plt.legend(handles=legend_elements, loc='center left', bbox_to_anchor=(1, 0.5), fontsize=12) # Increase legend font size
|
143 |
|
144 |
return plt
|
145 |
+
################################################################################################################################
|
146 |
def visualize_syntax(text, nlp, lang):
|
147 |
max_tokens = 5000
|
148 |
doc = nlp(text)
|