Comments (13)
@rtibbles @aronasorman can you put a ETA on this? Its a blocker for the MG channel.
from studio.
This should be achievable using a combination of https://github.com/transpect/mml2tex and then leveraging the xslt file in Python: http://stackoverflow.com/questions/16698935/how-to-transform-an-xml-file-using-xslt-in-python#answer-16699042
from studio.
The Perseus exercise renderer does not support MathML. Math formulas will need to be converted into latex format, and then inserted into the exercise text surrounded by $
symbols.
For example, if you put in $ f(x) = 2 ^ 3 $
, it will be rendered as:
(the tools that @rtibbles mentiones above may be helpful for doing this in an automated way)
from studio.
@rtibbles @aronasorman @jamalex For more clarification, will this issue be handled in ricecooker or we need to handle it in our code (i.e sushi chef). I remember @aronasorman @jayoshih had taken care of the same issue before in ricecooker itself.
from studio.
@yogeshmhaskule See #222 You'll need to convert it to latex to bypass the html escaping using the tools @rtibbles mentioned
from studio.
@jayoshih @aronasorman If you provide sample example of convert mathml data to latex in "Sample program file". So we can take reference from it. It will helpful to us to move forward.
from studio.
Again, as this isn't something we support in the ricecooker, it's the responsibility of the sushi chef to convert into usable formats. You can use whatever tools you want to do the conversion, before passing it into the ricecooker.
Here's an example:
- Install
xsltproc
(e.g., on Ubuntu,sudo apt-get install xsltproc
) - Download and unzip these xslt specifications
- Run a file with MathML in it through the converter:
> cat test.mml
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mfrac>
<mrow><mi>x</mi></mrow>
<mrow><mi>y</mi></mrow>
</mfrac>
</mrow>
</math>
> xsltproc mmltex.xsl test.mml > test.tex
> cat test.tex
$ \frac{x}{y}$
You can either use a tool like that and run it from Python via subprocess, or you may be able to plug those xslt definitions into the tool @rtibbles linked to do it directly within Python.
from studio.
@jamalex @aronasorman I went through the xsltproc
and it's working for me. But few of mathml questions are not rendering properly onto kolibri. This issue is specially to mathml which contains text. Latex conversion of same question is $ Convert the improper fraction into whole number.\phantom{\rule{0ex}{0ex}}\frac{12}{3}$
. And same data shown on cc server. After importing the questions onto kolibri. It removes the white spaces between question text (Converttheimproperfractionintowholenumber.).
Screenshot of cc
Screenshot of kolibri
from studio.
@yogeshmhaskule Can you post the full source HTML & MathML for that source question into the issue here? It seems as if the first sentence should be left outside the $
, as it's not a math formula.
from studio.
@jamalex Below is the response of same question.
{
'48113': {
'success': True,
'question': {
'answer_type': 'number',
'id': 48113,
'topic_id': 2890,
'unit': None,
'difficulty_level': 1,
'content': '<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi><mi>o</mi><mi>n</mi><mi>v</mi><mi>e</mi><mi>r</mi><mi>t</mi><mo> </mo><mi>t</mi><mi>h</mi><mi>e</mi><mo> </mo><mi>i</mi><mi>m</mi><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mo> </mo><mi>f</mi><mi>r</mi><mi>a</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo> </mo><mi>i</mi><mi>n</mi><mi>t</mi><mi>o</mi><mo> </mo><mi>w</mi><mi>h</mi><mi>o</mi><mi>l</mi><mi>e</mi><mo> </mo><mi>n</mi><mi>u</mi><mi>m</mi><mi>b</mi><mi>e</mi><mi>r</mi><mo>.</mo><mspace linebreak="newline"/><mfrac><mn>12</mn><mn>3</mn></mfrac></math>'
},
'possible_answers': [{
'question_id': 48113,
'content': '4',
'id': 114224,
'is_correct': True
}]
}
}
Here is the another mathml question where xsltproc
working properly also it shows the content properly onto kolibri.
{
'100755': {
'success': True,
'question': {
'answer_type': 'number',
'id': 100755,
'topic_id': 2890,
'unit': None,
'difficulty_level': 1,
'content': 'Convert <math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>30</mn><mn>3</mn></mfrac></math> into a whole number.'
},
'possible_answers': [{
'question_id': 100755,
'content': '10',
'id': 192953,
'is_correct': True
}]
}
}
Screenshot of working mathml conversion onto kolibri
from studio.
The MathML in the first example doesn't seem quite proper. It splits each letter of the non-math content into separate symbols. When I render it using an online MathML renderer, I get:
The format of the second example (which renders properly) looks correct -- non-math text is outside of the <math>
block.
from studio.
@jamalex There are quite a few questions on MagoGenie front, that are of the first type (The entire question with the text declared as Math ML). Is there a way to work around for these set of questions.
For the second one, its not a problem since only the equations or the formulas are declared as MathML and we can import them without road block.
from studio.
It will probably require a pre-processing stage that detects and extracts the non-math text from the MathML block, before going through xsltproc
. Depending on how consistently this content is marked up, it may be possible to do this with regular expressions, or else through parsing with an XML parser like lxml
or maybe BeautifulSoup
.
To more easily test final output and how it will look in Kolibri, you can use this tool:
http://khan.github.io/perseus/
(Put the output text in the Question box, and click "view rendered")
from studio.
Related Issues (20)
- Dropdown Arrow Button doesn't work properly HOT 2
- Clipboard doesn't always show correct channel thumbnail HOT 3
- With rebranded color scheme, card hover state should render box shadow HOT 1
- More cosmetic issues with rebranded cards HOT 2
- Update collection cards UI to use non-flat cards
- Update `Import from other channels` page to display recommendations
- Implement `About recommendation` modal
- Implement pagination for recommended resources
- [WIP - DO NOT ASSIGN]: Implement loading states and errors for recommended resources HOT 1
- [WIP - DO NOT ASSIGN]: Update `Import from other channels` page responsiveness HOT 1
- Import from other channels - The 'Save search' option is not working HOT 1
- Hotfixes - Cannot import newly created channels in Kolibri (as well as some other channels) HOT 2
- Hotfixes - Getting 'The specified key does not exist' error for a pdf in Arabic HOT 2
- Allow upload of BloomPub files
- Introduce KTextTruncator component for text truncation
- Use the latest KCard for the RecommendedResourceCard and remove the Studio KCard prototype files HOT 1
- Task context manager not properly clearing old task results
- Updating content nodes: Issues with saving when swapping in new file HOT 3
- Links leading outside Studio need to have a pop out icon HOT 14
- Date on Staging channel link not the latest version's date HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from studio.