gipplab / LaCASt

LaCASt - A LaTeX Translator for Computer Algebra Systems
MIT License
7 stars 1 forks source link

Using vmext-demo endpoints #208

Closed AndreG-P closed 3 years ago

AndreG-P commented 3 years ago

Please close this issue once @physikerwelt implemented the frontend (#193)

Endpoints are online at: https://vmext-demo.formulasearchengine.com/swagger-ui.html#/math-controller

You need 2 endpoints.


POST /math/generateAnnotatedDependenyGraph: Input:

Output: Base dependency graph of the document (this represents the context)


POST /math/generateTranslatedComputedMoi: Input:

Output: A single MOI representation for the given formula include definiens, translations, semantic LaTeX etc.


Example

You have a document:

The Gamma function <math>\Gamma(z)</math> and the pochhammer symbol <math>(a)_n</math> are often used together.

You generate a dependency graph from this document via: /math/generateAnnotatedDependencyGraph:

{
  "title": "unknown-title",
  "formulae": [
    {
      "id": "FORMULA_c5accc69791b469f2ce6bde7e27a4506",
      "formula": "\\Gamma(z)",
      "translations": {},
      "positions": [
        {
          "section": 0,
          "sentence": 0,
          "word": 3
        }
      ],
      "includes": [],
      "isPartOf": [],
      "definiens": [
        {
          "definition": "Gamma function",
          "score": 0.722
        },
        {
          "definition": "pochhammer symbol",
          "score": 0.7125985104912714
        }
      ]
    },
    {
      "id": "FORMULA_dc98955995146aae17dcfbcafaf4cb09",
      "formula": "(a)_n",
      "translations": {},
      "positions": [
        {
          "section": 0,
          "sentence": 0,
          "word": 8
        }
      ],
      "includes": [],
      "isPartOf": [],
      "definiens": [
        {
          "definition": "pochhammer symbol",
          "score": 0.722
        },
        {
          "definition": "Gamma function",
          "score": 0.7125985104912714
        }
      ]
    }
  ]
}

Next, you use this dependency graph to analyze the equation:

(z)_n = \frac{\Gamma(z+n)}{\Gamma(z)}

Because of the context (the dependency graph) we will find out that (z)_n is the pochhammer symbol and \Gamma(z) the gamma funciton. Let's analyze it via /math/generateTranslatedComputedMoi which takes the latex expression and the dependency graph from above and returns this:

{
  "id": "FORMULA_820f0958d955e5725b32d8aea5eb2945",
  "formula": "(z)_n = \\frac{\\Gamma(z+n)}{\\Gamma(z)}",
  "semanticFormula": "\\Pochhammersym{z}{n} = \\frac{\\EulerGamma@{z + n}}{\\EulerGamma@{z}}",
  "confidence": 0.6423131046028165,
  "translations": {
    "Mathematica": {
      "translation": "Pochhammer[z, n] == Divide[Gamma[z + n],Gamma[z]]",
      "numericResults": {
        "result": "SUCCESS",
        "wasAborted": false,
        "numberOfTests": 21,
        "numberOfFailedTests": 0,
        "numberOfSuccessfulTests": 21,
        "testCalculations": []
      },
      "symbolicResults": {
        "result": "SUCCESS",
        "numberOfTests": 1,
        "testCalculations": [
          {
            "property": "Simple",
            "result": "0",
            "wasAborted": false,
            "wasConditionallySuccessful": false
          }
        ]
      }
    },
    "Maple": {
      "translation": "pochhammer(z, n) = (GAMMA(z + n))/(GAMMA(z))",
      "numericResults": {
        "result": "ERROR",
        "wasAborted": false,
        "numberOfTests": 0,
        "numberOfFailedTests": 0,
        "numberOfSuccessfulTests": 0,
        "testCalculations": []
      },
      "symbolicResults": {
        "result": "SUCCESS",
        "numberOfTests": 1,
        "testCalculations": [
          {
            "property": "Simple",
            "result": "0",
            "wasAborted": false,
            "wasConditionallySuccessful": false
          }
        ]
      }
    }
  },
  "positions": [],
  "includes": [
    "\\Gamma(z)",
    "(a)_n"
  ],
  "isPartOf": [],
  "definiens": []
}

As you can see, it does not have a position, not definiens because the equation does not exist in the given dependency graph. Also, you see "result": "ERROR" for Maples numerical test. This was because the JVM crashed. But we were able to recover from it and run the symbolic test anyway which returned successful.

physikerwelt commented 3 years ago

Can you change the urls so that they are prefixed with /api/ also there should be a /_info endpoint, so that the API can identify itself as API. Also the version number should be part of the URL. https://vmext-demo.formulasearchengine.com/api/v2/ See https://stackoverflow.com/questions/389169/best-practices-for-api-versioning otherwise MathSearch would break if the API ever was refactored.