## 3 Methodology
### Scene Decomposer
#### 3.2.2 Implementation of COS Prompting Method
In QRAN, the algorithm first obtains the vector sequence \(h(w_{i})^{s}\) of the scene text using MWP-BERT [31]. It then calculates the attention score \(a\) of the mean vector \(h(s)\) for each quantity word vector \(h(q)\), and finally, the vector \(v\) for classification is obtained by the attention-weighted sum of \(h(q)\). This vector is used to predict the scene type \(\hat{l}\) through a single-layer network. The training setup of the QRAN follows the description in [17]. For explicit relations, the algorithm has developed a three-step matching process. The first step is the matching of scene types, which matches the 'L' part of the Scene-Aware \(S^{2}\) model to the predicted \(\hat{l}\) from QRAN, thus filtering applicable models from the model pool. The second step is the matching of the POS structure, which utilizes an N-LTP [35] tool to parse the POS tags of scene text, then matches it to the 'P' part of the candidate models. The third step is keyword matching, which is accomplished by using vector matching to compute the keywords 'K' in the model and the words in the scene text that occupy the same position in the POS. \begin{table}
\begin{tabular}{l c c c} \hline \hline
**Scene Type** & **Model Structure** & **Matched Sentence** & **Explicit Relations** \\ \hline \multirow{2}{*}{General} & n m q & \multirow{2}{*}{Ming had 15 stamps} & \multirow{2}{*}{Ming = 15 \(\times\) stamp} \\  & a = n; b = m; c = q & & \\  & a = b * c & & \\ \hline \multirow{2}{*}{General} & n m [more than] n & \multirow{2}{*}{Pens are 5 more than} & \multirow{2}{*}{Pen = 4 + Eraser} \\  & a = n; b = m; c = n & & \\  & a = b + c & & \\ \hline \multirow{2}{*}{General} & n [of] n [times] n [times] n [times] n & \multirow{2}{*}{The price of durian is} & \multirow{2}{*}{Price (durian) = 5 \(\times\)} \\  & a = n; b = n; c = m; d = n & 5 times that of apple} & \multirow{2}{*}{Price (apple)} \\  & a (b) = c * a (d) & & \\ \hline \multirow{2}{*}{Change} & n m q [left] & \multirow{2}{*}{The match is still 2 cm} & \multirow{2}{*}{Left (match) = 2 \(\times\) cm} \\  & a = n; b = m; c = q & & \\  & Left (a) = b * c & & \\ \hline \multirow{2}{*}{Rate and Journal} & n [average] m q [per] q & \multirow{2}{*}{The factory binds an average of 90 books per day} & \multirow{2}{*}{Rate (factory) = 90 \(\times\)} \\  & a = n; b = m; c = q; d = q & & \\  & Rate (a) = b * (c/d) & & \\ \hline \multirow{2}{*}{Discount} & n [at] m [discount] & \multirow{2}{*}{A product is sold at a = n; b = m} & \multirow{2}{*}{Discount (product) = 10\% discount} \\  & & Discount (a) = b & \\ \hline \multirow{2}{*}{Solution} & n [made of] n n [ratio of] q & \multirow{2}{*}{An alcohol is made of ethanol and water in a = n; b = n; c = n; d = q} & \multirow{2}{*}{An alcohol is made of ethanol and water in a (ethanol) \(\times\) Solvent} \\  & a = n; b = n; c = n; d = q & & \\  & Solution (a), Solute (b)/Solvent (c) = d & & \\ \hline \hline \end{tabular} Note: [\(\ast\)] indicates the keywords in model; a(b) indicates the attribute a of entity b.

\end{table} 
Table 2: The Scene-Aware \(S^{2}\) models. For implicit relations, the algorithm first uses text matching to align the concepts in implicit templates to the entities in explicit relations. Then, for those unmatched concepts, this algorithm concatenates the vectors of the two words and feeds them into a trained binary classification network \(BCN(\cdot)\) to verify whether they match. Finally, it converts the implicit template into a relation by replacing concepts with entities and adds it to the relation set.