グカネータ / 質問パターン見直し (#41) #365
@@ -674,6 +674,120 @@ const isQuestionRedundantAfterAnswers = (
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const isSourceFactBlocked = (
|
||||||
|
candidate: GekanatorQuestion['condition'],
|
||||||
|
previous: GekanatorQuestion['condition'],
|
||||||
|
answer: GekanatorAnswerValue,
|
||||||
|
): boolean => {
|
||||||
|
if (candidate.type !== 'source' || previous.type !== 'source')
|
||||||
|
return false
|
||||||
|
|
||||||
|
switch (answer)
|
||||||
|
{
|
||||||
|
case 'yes':
|
||||||
|
return true
|
||||||
|
case 'no':
|
||||||
|
return candidate.host === previous.host
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const isOriginalYearFactBlocked = (
|
||||||
|
candidate: GekanatorQuestion['condition'],
|
||||||
|
previous: GekanatorQuestion['condition'],
|
||||||
|
answer: GekanatorAnswerValue,
|
||||||
|
): boolean => {
|
||||||
|
if (candidate.type !== 'original-year' || previous.type !== 'original-year')
|
||||||
|
return false
|
||||||
|
|
||||||
|
switch (answer)
|
||||||
|
{
|
||||||
|
case 'yes':
|
||||||
|
return true
|
||||||
|
case 'no':
|
||||||
|
return candidate.year === previous.year
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const isOriginalMonthFactBlocked = (
|
||||||
|
candidate: GekanatorQuestion['condition'],
|
||||||
|
previous: GekanatorQuestion['condition'],
|
||||||
|
answer: GekanatorAnswerValue,
|
||||||
|
): boolean => {
|
||||||
|
switch (answer)
|
||||||
|
{
|
||||||
|
case 'yes':
|
||||||
|
if (previous.type === 'original-month')
|
||||||
|
{
|
||||||
|
if (candidate.type === 'original-month')
|
||||||
|
return true
|
||||||
|
|
||||||
|
if (candidate.type === 'original-month-day')
|
||||||
|
return monthForCondition (candidate) !== previous.month
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous.type === 'original-month-day')
|
||||||
|
return candidate.type === 'original-month'
|
||||||
|
|| candidate.type === 'original-month-day'
|
||||||
|
|
||||||
|
return false
|
||||||
|
case 'no':
|
||||||
|
if (previous.type === 'original-month')
|
||||||
|
{
|
||||||
|
if (candidate.type === 'original-month')
|
||||||
|
return candidate.month === previous.month
|
||||||
|
|
||||||
|
if (candidate.type === 'original-month-day')
|
||||||
|
return monthForCondition (candidate) === previous.month
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous.type === 'original-month-day')
|
||||||
|
return candidate.type === 'original-month-day'
|
||||||
|
&& candidate.monthDay === previous.monthDay
|
||||||
|
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const isFactQuestionBlocked = (
|
||||||
|
candidate: GekanatorQuestion['condition'],
|
||||||
|
previous: GekanatorQuestion['condition'],
|
||||||
|
answer: GekanatorAnswerValue,
|
||||||
|
): boolean => {
|
||||||
|
if (!(answer === 'yes' || answer === 'no'))
|
||||||
|
return false
|
||||||
|
|
||||||
|
return isSourceFactBlocked (candidate, previous, answer)
|
||||||
|
|| isOriginalYearFactBlocked (candidate, previous, answer)
|
||||||
|
|| isOriginalMonthFactBlocked (candidate, previous, answer)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const isQuestionHardFilteredAfterAnswers = (
|
||||||
|
question: GekanatorQuestion,
|
||||||
|
answers: GekanatorAnswerLog[],
|
||||||
|
): boolean => answers.some (answer => {
|
||||||
|
const previous = answer.questionCondition
|
||||||
|
if (previous === undefined)
|
||||||
|
return false
|
||||||
|
|
||||||
|
return isQuestionRedundantAfterAnswers (question, [answer])
|
||||||
|
|| isFactQuestionBlocked (question.condition, previous, answer.answer)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const isMonthCrossMatch = (
|
const isMonthCrossMatch = (
|
||||||
candidate: GekanatorQuestion['condition'],
|
candidate: GekanatorQuestion['condition'],
|
||||||
previous: GekanatorQuestion['condition'],
|
previous: GekanatorQuestion['condition'],
|
||||||
@@ -808,7 +922,7 @@ const chooseQuestion = ({
|
|||||||
|
|
||||||
return questionsToRank
|
return questionsToRank
|
||||||
.map (question => {
|
.map (question => {
|
||||||
if (isQuestionRedundantAfterAnswers (question, answers))
|
if (isQuestionHardFilteredAfterAnswers (question, answers))
|
||||||
return null
|
return null
|
||||||
|
|
||||||
const signature = signatureFor (question, candidates)
|
const signature = signatureFor (question, candidates)
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする