« first day (39 days earlier)    last day (15 days later) » 

11:57 AM
Hello @Grischa
 
Hello @Nobody
I have add the function starts_with_vowel with working tests, but the apostroph function didn't work in all cases
 
is the code on github?
 
yes
 
is there any reason to use in_array($consonant) instead of !in_array($vowel)?
 
I get the same erros with: if (!in_array ( mb_substr ( $verb, 0, 1 ), $french_vowels )) { // line 807
 
12:11 PM
that was just a change that should improve readability without changing the behavior of the code
 
ok
 
the problem is probably that $verb is a conjugated verb which is compared to infinitives in the $h_apire list and in $verb == 'ypériter
I will write some changes and push them to show you what I mean
 
ok
 
it seems the logic is inverted
the function starts_with_vowel returns false when the verb starts with a vowel
 
So my StartVowelTest tests are not working correct?
 
12:20 PM
no they seem okay, I think I got confused by multiple negations
when you only return true/false it does not make much sense to use ifs
 
What can be used instead of using ifs?
 
I'll push that as well, wait a moment
I pushed the code
 
great
Now, I have only add the changed ending for SentenceType::InterrogativeSentence for the first person
Or should we first improve the whole create function?
 
you mean the cascading ifs?
 
@Nobody You mentioned it here
 
12:36 PM
as I said I would want you to get it reviewed by others, not me
when it works
 
One part should be merged: if ($auxiliaire->getValue () === Auxiliaire::Etre || $voice->getValue () === Voice::Passive) { I have this condition twice, once for composite und once for !composite, but it works for both
 
then you should invert the order of the ifs
 
lines 857-867 and 984-994
I would add this rules before if (isComposite ( $mood, $tense )) {
 
you could also put it into its own function and call that function in the appropriate cases
 
you mean also in case a composite and case b non-composite?
 
12:45 PM
you just extract the code that is the same into a function
that would be the code on the lines that you described
 
function participe_ending_suffix_passive_etre(Auxiliaire $auxiliaire, Voice $voice, Gender $gender, Person $person) {
if ($auxiliaire->getValue () === Auxiliaire::Etre || $voice->getValue () === Voice::Passive) {
if ($gender->getValue () === Gender::Masculine && (isPlural ( $person ))) {
$participe_passe .= 's';
}
if ($gender->getValue () === Gender::Feminine && (! isPlural ( $person ))) {
$participe_passe .= 'e';
}
if ($gender->getValue () === Gender::Feminine && (isPlural ( $person ))) {
$participe_passe .= 'es';
 
the variable $participe_passe has to be passed to this function as well
if you want to keep the code as it is you should pass it as a reference parameter
 
ok, should it be a static function in abstract class ConjugationPhrase?
 
yes
 
I can call the function with: ConjugationPhrase::participe_ending_suffix_passive_etre( $auxiliaire, $voice, $gender, $person, $participe_passe) ?
because participe_ending_suffix_passive_etre( $auxiliaire, $voice, $gender, $person, $participe_passe); is unknown for the script
 
12:56 PM
is the code on github?
 
no
I have pushed it now, but with unknown function error
 
1:23 PM
@Grischa okay, you can call the function that way
however, you need to define the parameter $participe_passe as reference parameter
 
you mena adding a & to the reference parameter?
it is working for the first case ...
 
@Grischa yes
 
the script is very slow now, is it because of the many long arrays?
 
maybe
you would have to profile to know for sure
 
I have add a something for the whole script
 
1:32 PM
which something?
 
$time = microtime(TRUE);
$mem = memory_get_usage();
print_r(array(
'memory' => (memory_get_usage() - $mem) / (1024 * 1024),
'seconds' => microtime(TRUE) - $time
));
 
that gives you an overall look but you need more detailed information
200
A: Simplest way to profile a PHP script

mercutioYou want xdebug I think. Install it on the server, turn it on, pump the output through kcachegrind (for linux) or wincachegrind (for windows) and it'll show you a few pretty charts that detail the exact timings, counts and memory usage (but you'll need another extension for that). It rocks, seri...

 
I have read this already.
I do not run the script in localhost like you.
 
I don't as well and the description is about running it on a remote serevr
 
I don't think, I can use Xdebug on the server
Lets finish the last error
I need to replace the the last ending letter if it is an 'e' to 'é' for [Mood::Indicatif][Tense::Present][Person::FirstPersonSingular] for $sentencetype->getValue () === SentenceType::InterrogativeSentence
should I add this in ending.php?
 
1:47 PM
is it part of the conjugation?
 
yes, is a a rule only for InterrogativeSentence
 
okay, is that independent of the infinitive ending?
 
important is only, if the ending is 'e'
aime -> aimé , finis -> finis
 
the ending of the infinitive or of the conjugated verb
 
conjugated verb
 
1:58 PM
okay so it depends on the result of the ending function, right?
 
yes
 
then you should use the function ending to add that
also, the monstrous switch is a bit unnecessary
 
How to improve it?
 
could you push one example?
 
2:12 PM
you only need one example
you replace the whole switch by something like:
call_user_func('ending_'.$exceptionModel->getValue (), array(/*parameters*/));
there are some functions that would have to be renamed though
e.g. ending_passe_subjonctif_changes_re -> ending_vivre
you could add definitions of forwarding functions that deal with that
 
call_user_func('ending_'.$exceptionModel->getValue (), [ExceptionModel::strtoupper($exceptionModel->getValue ())]);
ending_passe_subjonctif_changes_re, ending_ire_with_iss and ending_ire should be using not only for one array
 
as I said you can write functions like ending_vivre that internally just call ending_passe_subjonctif_changes_re
I don't see why you would need strtoupper
 
2:28 PM
@Nobody I don't understrand this part
 
as I said, you would use the call_user_func as I wrote and for those functions that are used multiple times you would write forwarding functions like this:
function ending_vivre($person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb) {
    return ending_passe_subjonctif_changes_re ( $person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb );
}
 
do I have to change here: ExceptionModel::ETRE_IRR :
return ending_etre
to ExceptionModel::ETRE (without _IRR)
 
no
you would just write another forwarding function name ending_etre_irr that forwards to ending_etre
 
but the array is called $aller_irr
 
so?
 
2:36 PM
the function should be called ending_aller_irr
not ending_aller
 
if there is only one call to this function you can rename it directly
otherwise you should add a forwarding function
 
2:48 PM
Fatal error: Uncaught Error: Access to undeclared static property: IrregularExceptionGroup::$exceptionModel
call_user_func('ending_'.$exceptionModel->getValue (), [IrregularExceptionGroup::$exceptionModel->getValue ()]);
from conjugate.php : $irregularExceptionGroupArray = [
ExceptionModel::ALLER => IrregularExceptionGroup::$aller, ...
 
why did you prefix that with IrregularExceptionGroup::?
try: call_user_func('ending_'.$exceptionModel->getValue (), $person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb);
 
I would get Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in Enum.php line 35
 
um that is bad
 
, $person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb isn't an array ... or?
 
I think it does not need to be an array
 
2:58 PM
should I pushed my changes?
 
yes
 
pushed it
 
I get an endless recursion in ending_re
ah, I see the problem
the previous code returned when it found the correct function
the current code does not
it would need to check if a function with the name exists and if so return its result, else it should go on with the second (now first) switch
 
could you pushed it?
 
yes, there are many errors
I believe some forwarding functions are missing
 
3:10 PM
because ending_ir is used often at the end of the ir-exceptions?
 
pushed
you would have to go through the old switch code and write a forwarding function for each case where the function does not end in the case name
 
did you sync your changes?
 
yes
 
I think the only functions are ending_ir_with_iss and ending_ir_without_iss
I don't know, what forwarding functions are
could you add it for this 2 function here:
case EndingWith::IR :
return ending_ir ( $person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb );
 
that is a forwarding function:
54 mins ago, by Nobody
function ending_vivre($person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb) {
    return ending_passe_subjonctif_changes_re ( $person, $tense, $mood, $endingwith, $exceptionModel, $infinitiveVerb );
}
it forwards the call to ending_vivre to ending_passe_subjonctif_changes_re
 
3:26 PM
I thought I have written all forwarding functions ..
I only had such cases for verbs not ending with -IR
 
I pushed some more changes
now I only get failures and no errors in the test
 
I see, I found only one mistake in the name of a forwarding function
naitre instead of naitre, but I have 111 failures
often ending_ire_with_iss isn't used
 
you should be able to guess which ending function is responsible for the failing cases, right?
 
3:42 PM
yes
 
for example ExceptionModel::OITRE has value croitre which would lead to the wrong function
similarly ExceptionModel::AITRE = "paitre"
I've got to go now
sry
 
4:02 PM
me, too
 

« first day (39 days earlier)    last day (15 days later) »