3131kFeatureColor = 'Purple'
3232kSemanticsColor = 'Blue'
3333kLexicalColor = 'Black'
34+ kEntityColor = 'Green'
35+ kPosColor = 'Green'
3436# The full list of colors is:
3537# Black Green Silver Lime Gray Olive White Maroon Red Purple Fuchsia Yellow Navy
3638# Blue Teal Aqua
@@ -78,6 +80,20 @@ def get_surface_mathml(surface):
7880 + surface \
7981 + "</mtext>\n "
8082
83+ def get_entity_mathml (entity ):
84+ return "<mtext " \
85+ + " fontsize='" + str (kOtherSize ) + "'" \
86+ + " color='" + kEntityColor + "'>" \
87+ + entity \
88+ + "</mtext>\n "
89+
90+ def get_pos_mathml (pos ):
91+ return "<mtext " \
92+ + " fontsize='" + str (kOtherSize ) + "'" \
93+ + " color='" + kPosColor + "'>" \
94+ + pos \
95+ + "</mtext>\n "
96+
8197def get_semantics_mathml (semantics ):
8298 return "<mtext " \
8399 + " fontsize='" + str (kOtherSize ) + "'" \
@@ -94,7 +110,29 @@ def convert_node_to_mathml(ccg_node, sem_tree, tokens):
94110 token = find_node_by_id (token_id , tokens )
95111 surf = token .get ('surf' )
96112 surf_mathml = get_surface_mathml (surf )
97- mathml_str = get_fraction_mathml (category_mathml , surf_mathml , '0' )
113+ pos = token .get ('pos' )
114+ pos_mathml = get_pos_mathml (pos )
115+ entity = token .get ('entity' )
116+ if not entity == None :
117+ entity_mathml = get_entity_mathml (entity )
118+ pos_mathml = pos_mathml + "<mtext>,</mtext><mspace width='.1em'/>" + entity_mathml
119+ pos1 = token .get ('pos1' )
120+ if not (pos1 == None or pos1 == '*' ):
121+ pos1_mathml = get_pos_mathml (pos1 )
122+ pos_mathml = pos_mathml + "<mspace width='.1em'/>" + pos1_mathml
123+ pos2 = token .get ('pos2' )
124+ if not (pos2 == None or pos2 == '*' ):
125+ pos2_mathml = get_pos_mathml (pos2 )
126+ pos_mathml = pos_mathml + "<mspace width='.1em'/>" + pos2_mathml
127+ pos3 = token .get ('pos3' )
128+ if not (pos3 == None or pos3 == '*' ):
129+ pos3_mathml = get_pos_mathml (pos3 )
130+ pos_mathml = pos_mathml + "<mspace width='.1em'/>" + pos3_mathml
131+ if pos == '.' :
132+ mathml_str = get_fraction_mathml (category_mathml , surf_mathml , '0' )
133+ else :
134+ mathml_pos_str = get_fraction_mathml (category_mathml , pos_mathml , '0' )
135+ mathml_str = get_fraction_mathml (mathml_pos_str , surf_mathml , '0' )
98136 elif len (ccg_node ) == 1 :
99137 mathml_str_child = convert_node_to_mathml (ccg_node [0 ], sem_tree , tokens )
100138 rule = ccg_node .get ('rule' )
0 commit comments