ml4ai / skema

SKEMA: Scientific Knowledge Extraction and Model Analysis
https://ml4ai.github.io/skema/
Other
10 stars 4 forks source link

`/mml/amr` fails to process valid pmml #287

Closed myedibleenso closed 1 year ago

myedibleenso commented 1 year ago

This example comes from converting the following Lotka-Volterra equations from pmml to AMR:

curl -X 'PUT' \
  'http://localhost:8080/mathml/amr' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"mathml": [
  "<math><mfrac><mrow><mi>d</mi><mi>x</mi></mrow><mrow><mi>d</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mi>α</mi><mi>x</mi><mo>−</mo><mi>β</mi><mi>x</mi><mi>y</mi></math>",
  "<math><mfrac><mrow><mi>d</mi><mi>y</mi></mrow><mrow><mi>d</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mi>δ</mi><mi>x</mi><mi>y</mi><mo>−</mo><mi>γ</mi><mi>y</mi></math>"
], "model": "regnet"}'

Error:

skema-rs | thread 'actix-rt|system:0|arbiter:35' panicked at 'We cannot handle expressions with more than one top-level MathExpression yet!', mathml/src/mml2pn.rs:76:9

myedibleenso commented 1 year ago

That error seems to come from here: https://github.com/ml4ai/skema/blob/a00595ffba35b8e525794e6a0593461db6420834/skema/skema-rs/mathml/src/mml2pn.rs#L74-L77

I believe @adarshp added that.

Free-Quarks commented 1 year ago

Yeah this is likely related to some mrow constraints that do exist, and could maybe be relaxed. Namely every equation needs to start with < math>< mrow> and end with </ mrow></ math>.

adarshp commented 1 year ago

@Free-Quarks is correct, we currently expect the top-level equation to be wrapped in an . This was done for expediency, and also since the img2mml pipeline seems to always produce a top-level within a element. My reasoning was also that if humans are manually entering mml, they could just enter cMML, whereas the img2mml pipeline could not directly produce cMML.