[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu-devel
Subject:    [kde-edu]: Changes in kvtml
From:       Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date:       2007-04-22 16:34:00
Message-ID: 200704221834.08329.frederik.gladhorn () gmx ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi all!
Ok, it took me a while, but I started playing around with the kvtml stuff in 
the lib. I was getting frustrated every time I looked at the KVocTrain code, 
so I decided I have to act.
There are six weeks left until feature freeze, and I'd like to make a rather 
big chage, that will trouble all that are using our beloved KVTML file 
format.

For lawyers: I'll be using language for things that can be in KVTML docs. 
These  can of course be totally different things, which is the cause to call 
them identifiers in the lib. Feel free to fill in whatever you like instead.

The concept of original language + x translations is not really great for apps 
that actually can have more than two languages. So far it is never possible 
to practice language 2 with language 3.
This is intersting for people learing eg. Chinese or Japanese, to have some 
sort of signs and maybe traditional and simplified and be able to practice 
them in respect to each other.
See bug #93446 (https://bugs.kde.org/show_bug.cgi?id=93446).

Another thing is that this concept blows up the code unnecessarily and in a 
ugly way. Because everywhere there is special treatment for original, than an 
iteration over all translations.
KVocTrain and also the lib we have about thousand places like (rather small 
example of duplicate code directly next to each other):

(from keduvocdocument.cpp)
if (sort_column == 0)
        return e1.original().toLower() < e2.original().toLower();
      else
        return e1.translation(sort_column).toLower() < 
e2.translation(sort_column).toLower();

This will become:
return e1.translation(sort_column).toLower() < 
e2.translation(sort_column).toLower();

I modified KEduVocExpression as a start, to see how bad changing that is. I 
started with 950 lines of code and I ended up with 530 lines of code (ok, 
it's not tested and will grow a couple of lines again).

For most of the programs using it there will be little to no problems. The 
original() calls will have to be replaced by translation(0) and 
translation(0) becomes translation(1).

Only the grading has to be saved a little different, because now it will be 
possible to practice language 2 with 3, which is the point of the whole 
exercise.
Each word in every language can now save grades from the other language. So if 
I am shown a word in language 2 and enter it correctly in language 3, the 
lang 3 entry saves that it was correct one time from lang 2.
(Before there was a bool which decided if it was from or to original. See 
attachment.) 

The bigger problem is that this change will not be downward compatible. I'd 
adapt the original readers to provide the new structure. To keep 
KEduVocKvtmlReader clean I'd like to have two versions of it. One simply 
reading old files to the new structure and another one to read the new files.

The other big change is the use of lessons. To make KEduVocDocument a little 
cleaner I removed all references to lessons and vocabulary entries, exept two 
functions: rootLesson() and setRootLesson().
Lessons now actually contain their vocabulary and can contain sublessons.
This makes organization much nicer and removes many special case treatment as 
well.
For most apps (unless they begin to like lessons) this is no big change. 
Instead of myDoc->entry(index) it changes to 
myDoc->rootLesson()->entry(index).

Types will actually be a real class to fix bug #138488, that it was impossible 
to query 
for nouns and have noun:male/femal/nutral included.

The multiple choice class was a really weird container for five QString. I'd 
replace it with a QStringList which is more flexible and smaller. This also 
get's rid of the fixed maximum of multiple choice answers. Do you want to 
rather keep it?

Please send your suggestions and concerns!
Did something always annoy you with KEduVocDocument? Do you want a new 
comfortable function there? Will you burn me on a pile of wood for doing 
this?

I'd like to get this in soon, so all KDE4 kvtml apps make use from the change 
right from the beginning.

I think I will need one more week to get the lib done. If there are no 
protests I might actually apply this. I'll happily send out a patch to those 
interested. It's probably still a bit buggy, but if kvoctrain works with it, 
most of the other apps should as well.
Also tell me, if you want to port your app yourself or if I should do it.
Any help is of course very appreciated.

Attached: xml proposal (I think there are still some things mixed up, is the 
old one defined cleanly anywhere?)

At the moment, I have new lesson, expression and so on classes and almost 
finished writer/reader classes.

For kvoctrain I hope this makes it possible/necessary to fix:
#93446, #108568 (a bit), #125555, #138488 and #140039

Greetings,
Frederik

["new-kvtml" (text/html)]

Structure:

<kvtml>
  <identifiers>

    <!-- Language: gets l10n by looking up the twoAlpha code with KLocale -->
    <!-- Also permit a note to make a difference between same language twice (Chinese \
Traditional/Simplified) -->  <language id="0" twoAlpha="zh" note="Traditional">
       <article/> <!--article as before?-->
       <conjugation/>
    </language>

    <!-- User defined identifier is completely free. Can contain language stuff if \
needed -->  <userDefined id="1" name="Definition"/>
  </identifiers>

  <!-- unchanged so far: types and usage labels -->
  <types>
    <desc no="1" >My Type 1</desc>
  </types>
  <usage>
    <desc no="1">My usage 1</desc>
    <desc no="2">My usage 2</desc>
  </usage>

  <lessons>
    <lesson>
      <desc>Lesson 1</desc>
<!-- I don't like the short tags, but it's probably worth it to keep file size down. \
-->  <e> <!--entry-->
          <t id="0">Erbse</o> <!-- this is a translation into language 0 (see \
identifiers)-->  <t id="1">pea</t>
          <t id="2">pois</t>
      </e>

      <!--LESSONS MAY CONTAIN SUBLESSONS-->
      <lesson>
        <desc>Lesson 1.1</desc>
	<e><!--see above--></e>
      </lesson>

    <lesson>
      <desc>Lesson with grades example</desc>
	<e>
          <t id="0">Kniebeugen
                <g from="1" g="1" c="1" d="949757271"/>
                <g from="2" g="1" c="1" b="1" d="1234(date-UnixTime)">
          </t>
          <t id="1">genuflect
                <g from="0" g="3" c="2" d="934731856"/>
		<!-- this has been asked from 0(=Kniebeugen).
                     grade is %g=3, never answered wrong (%b=0),
                     it was asked %c=1 time, last at %d (QDateTime::toTime_t()) -->
          </i1>
          <t id="2">flexion de genoux
                <g from="0" g="4" c="1" b="1" d="1234">
          </t>
        </e>

    </lesson>
  </lessons>

</kvtml>


shortnames:
  <e entry>
    <t Translation id=Which language>
      <g(grading information) 
	from=LanguageId 
	g=grade(int) 
	c=count(how often asked) 
	b=bad count(how often false) 
	d=lastQueryDate />

The from should be seen as grade, when asked to answer this FROM language xy! So the \
current id is the TO id - that is what the user had to enter.

I would kill this without replacement unless it is used anywhere (?)
 <options>
  <sort on="1"/>
 </options>



In KVocTrain handling vocab without lesson is a pain, so it will stuff them all into \
a default lesson if none is defined. Other programs will still be able to use it as \
before.


[Attachment #8 (application/pgp-signature)]

_______________________________________________
kde-edu mailing list
kde-edu@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-edu


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic