我正在设置一个小数问题总和模板,如下所示:
Mark has 3 1/3 times as many apple as Jane. Jane has 42 apples. How many do they have altogether?
Template Possibility 1 - fraction first, then whole number
@name@1 has #name#1 #name#2/#mul#1 times as many @fruit@1 as @name@2. @name@2 has #name#3mul @fruit@1s. How many @fruit@1s do they have altogether?
Template Possibility 2 - whole number first , then fraction
Jane has 42 apples. Mark has 3 1/3 times as many apple as Jane.How many do they have altogether?
@name@1 has #name#1mul1 @fruit@1s. @name@2 has #name#2 #name#3/#mul#1 times as many @fruit@1 as @name@1. How many @fruit@1s do they have altogether?
Another possibility, there may be another pair : #name#2/#mul#1 #name#3mul1 #name#4/#mul#2 #name#5mul2
带#的是数字变量,带@的是文本变量。
对于文本变量和普通整数变量,我可以将值随机化并将其转入模板。
我遇到了分数(#name#2 / #mul#1)和整数(#name#3mul)的问题,其中这两个是以 #mul#1 分母必须能够将整数(#name#3mul)除以任何剩余或小数。
我有一种方法,在按顺序检查单词时,如果找到第一个#mul#1,它将调用一个方法并返回2个东西,整数和mul值本身。
现在我有一个问题是在问题模板中替换这2个值,因为整个数字可能先是分数。
你们中的任何一个人都曾经历过这种情况并且有更好的方法来生成可分割的分数和整数吗?
非常感谢任何建议或提示。谢谢!
PS:我和JAVA合作......
答案 0 :(得分:0)
如果你不能在数字字段中替换你想要使用的所有情况的字段,那么你必须进行计算以使它们符合。
这意味着将输入格式化为模板,以便出现的语义和语法正确。我可能事先计算出我想要的一切,并且这样做: