I'm developing an android app in which we're going to display some mathematics and physics question with multiple-choice answers.
The text of the questions are ready on a Microsoft Office Word .docx format.
The text of the questions usually contains formulas and equations and we want to save them in a SQLite database and access to it on android app.
The real problem is how to manage the displaying part, since to the best of my knowledge, we should manage such complex text with html tags.
There are actually about at least 2000 of these questions and we're after an optimized solutions for the problem.
and I'm a tough guy ! :) just give me some keywords and I'll go get it done.
So, please share your experiences and suggestions.
An easy solution, mentioned in the comments, would be to use MathJAX.
An alternative, if you only have about 2000 formulas, would be to set up TeX on your local machine, generate the formulas, and convert into individual png images.
You could also use HTML+Unicode directly if the formulas are simple.
Related
I am making a framework in order to easily "appify" books.
This framework will need to automatically detect chapter and heading to make a table of contents. The idea is to also be able to easily search through the text and find what you are looking for.
Now what I still need to figure out is:
how to store the data in such a way that I can easily detect the chapters and heading
and still be able to search through the text.
The text that is stored needs to be formatted, so I thought I would store them as HTML or Markdown (which will be translated to HTML). I don't think it would be very searchable if the text is in HTML.
P.S. it does not have to be HTML if there are other more efficient ways to format the text.
Do you really want to do such thing on the device itself?
I can suggest you to use separate sqlite database for every book. With separate tables for table of contents, chapters, summarized keywords of chapters(for faster search) and other service info.
Also here you can find full text search example
Also I recommend you to bring your own sqlite build with your app.
Now lets talk about the main problem of yours - the book scraping.
I have no competency here, I believe this problem is the same as the web sites scraping.
Upd:
Please do not store book contents as HTML, you can store it as markdown for example, it takes less amount of storage, easier to sanitize and you can always apply your styles later
I have a question concerning data storage in android and hope to get some help here. I've tried searching for it, but couldn't find anything specific to my question. Please feel free to point me in the right direction, if I missed something.
I'm very new to android programming, having mostly experience in C++ and C#.
For my first project I picked something small. I want to programm an app for my wife and me, which manages the contents of our freezers. ;) It's simple. You create a freezer, define a certain amount of compartments and then add content to those compartments, which contain certain attributes (food type, amount, weight, expiration date etc).
Now, obviously this "database" will not contain a hell of a lot of info. Maybe 50 items tops? So from what I gathered XML might be a good way to go.
However, this data will be modified quite often. Things will be added, removed, modified, moved from one compartment to another. Would sqlite be a better choice in that situation?
I would greatly appreciate any advice you guys and girls might have. Again, small database, lots of modifications along the way ... XML or sqlite?
Thanks a lot in advance. :)
Michael
Although XML will work, but in terms of modification (change the data) and persistence (write to disk), it is certainly not as easy as SQLite.
With XML, you are constantly dealing with the entire document, even when you just want to deal with a little piece of it.
I found the API dealing with XML are quite often not so intuitive.
To be honest, XML has already passed its most glorious time. At one point, people express virtually everything as Xml whenever they had a chance. But that time has passed, and that's clearly not the situation any more.
Growing is a major consideration here too. I understand that it is small, but the size is one side, and the structure is the other side, XML is less flexible in terms how much code change you need to make when the structure of data changes.
I m working on app which uses sqlite database . I got sucess to store Strings in various languages and also fetching from database .
But My problem is that i want to store it in bold or italic style.
Is it possible ?? If yes then how can i achieve that kind of thing ?
Any help will be appreciated.
Format the strings using html.
When you want to display them use Html.fromhtml( your string)
E.g.
String myboldstring = <b>boldy</b>
textView.setText(Html.fromhtml(myboldstring));
Is it what you want?
As an alternative to LazyN's solution I suggest you look at using a standard markdown language for this kind of context (much as stack overflow does). There are several advantages:
Widely used around the web so your users are likely to understand how to use it.
Much more secure in the sense that one cannot inject malicious HTML/javascript; this is very difficult to prevent once you allow any HTML as LazyN suggests
Trivial to store/export/import etc as it is all legal text string
I have some text files or html file. I want to retrieve some words from the text. My worry is that I have to do text-mining on mobile. Which algorithm can I use for text-mining on a mobile. A sample example would be appreciated.
I dont think that you need to do text mining on mobile, because the algorithms are mostly trained on servers on the cloud. Besides that, if you have a lot of files, you can overload the cellphone CPU.
If you have a few files, why don't you use regex?
Its difficult to give an example because you gave too little information about the case.
I think that you need to Google better this before, and return with a more especific question.
I'm working on a trivia like app and wondering how is the best way to store all of the questions and answers. Right now, I just have a random number and using a whole lot of if statements. For example, if randomNum = 25, then question is THIS and choices are THIS. This seems to work fine, but my file is starting to get very large and this seems like it should cause performance issues. Space is also starting to become an issue. I have started to look into just putting all of the data into database and use a random number to just retrieve a row. Anybody have any suggestions on which would be the best practice or have any other ways of doing this?
Sounds like its a good time to start using the database. You can learn how to include a pre-populated database here.
...using a whole lot of if statements.
I have started to look into just putting all of the data into database and use a random number to just retrieve a row
I think you've kinda answered the question yourself.
What happens with your model if you have 10,000 questions? Are you going to use 10,000 'if' statements?
Even if you're never going to get to that many questions, using a SELECT on a DB where the question number equals a particular random number, is going to be far more extensible.
You should use the database.
It's not just a maintainability and (ultimately) a code simplicity option, either, but offers significant advantages.
Imagine if you want to be able to supply different packs of questions, for example. You could offer people the ability to download a trivia pack from a website, or load it from a file off their SDcard. This simply would not work for masses of if statements.
Suppose you want to let people add their own trivia questions? Upload them to the website for voting and ultimate inclusion into crowd-sourced question packs.
So yeah: you should use a database.