コミットを比較

...

3 コミット

作成者 SHA1 メッセージ 日付
みてるぞ 1d11c01247 #371 ごみファイル削除 2026-06-17 01:04:26 +09:00
みてるぞ cb7b9ee808 #371 2026-06-17 00:56:31 +09:00
みてるぞ f9f0010e03 #371 2026-06-16 23:48:29 +09:00
10個のファイルの変更521行の追加436行の削除
+58
ファイルの表示
@@ -125,6 +125,64 @@ npm run preview
- TypeScript and TSX use 4-space logical indentation. - TypeScript and TSX use 4-space logical indentation.
- In TypeScript and TSX only, replace every leading run of 8 spaces with a tab. - In TypeScript and TSX only, replace every leading run of 8 spaces with a tab.
- Tabs are only for leading indentation, never for spaces after non-space text. - Tabs are only for leading indentation, never for spaces after non-space text.
- TypeScript and TSX imports may stay on one line if they remain within the
line limit; do not expand short type-only imports mechanically.
- In TypeScript and TSX, when a function takes one destructured object
argument plus an inline type, prefer this shape when it fits locally:
```ts
const helper = (
{ value, flag }: { value: string
flag: boolean },
): Result => {
// ...
}
```
- In TypeScript and TSX, put `switch` case block braces on their own lines
when a case needs a lexical block:
```ts
case 'yes':
case 'no':
{
const expected = valueFor (item)
return expected == null || expected === answer
}
```
- In TypeScript and TSX, use `value == null` and `value != null` as the
default nullish checks. Do not use `=== null`, `=== undefined`,
`!== null`, or `!== undefined`.
- If code appears to need a distinction between `null` and `undefined`, treat
that as a design smell and revise the logic to avoid the distinction.
External library APIs that explicitly require distinguishing the two are the
only exception.
- In TypeScript and TSX, keep short arrays on one line when they fit under the
line limit; break arrays only when readability or line length requires it.
- In TypeScript and TSX, when a ternary expression is split across multiple
lines, align `?` and `:` with the condition expression. Do not indent `?` and
`:` one extra level under the condition.
```ts
const value =
condition
? consequent
: alternate
```
- In TypeScript and TSX, keep short ternary expressions on one line when they
fit cleanly under the line limit.
- In TypeScript and TSX, prefer ternary expressions for simple conditional
value selection. Do not replace a clear ternary with `if` statements, and do
not introduce immediately invoked functions just to avoid or reformat a
ternary expression.
- In TypeScript and TSX, do not write `let` followed by later `if` assignments
when the value can be expressed as a single `const` initializer. Prefer
`const` because it prevents accidental later reassignment.
- When fixing formatting, change formatting only. Do not change expression
structure, control flow, or variable mutability unless the requested style
explicitly requires it.
- Do not add production dependencies without explicit approval. - Do not add production dependencies without explicit approval.
- Do not create, modify, or run tests unless the user explicitly asks for - Do not create, modify, or run tests unless the user explicitly asks for
test work. When the user asks for tests, keep working and rerun them until test work. When the user asks for tests, keep working and rerun them until
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 559 KiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 146 KiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 1.2 MiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 188 KiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 201 KiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 196 KiB

バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 179 KiB

+59 -83
ファイルの表示
@@ -1,43 +1,33 @@
import { expectedAnswerForQuestion } from '@/lib/gekanator' import { expectedAnswerForQuestion } from '@/lib/gekanator'
import type { import type { GekanatorAnswerLog, GekanatorAnswerValue, GekanatorQuestion } from '@/lib/gekanator'
GekanatorAnswerLog,
GekanatorAnswerValue,
GekanatorQuestion,
} from '@/lib/gekanator'
import type { Post } from '@/types' import type { Post } from '@/types'
export type RecoveredCandidatePost = { export type RecoveredCandidatePost = {
postId: number postId: number
answerCountAtRecovery: number } answerCountAtRecovery: number }
const questionIsFactLikeForHardFiltering = ( const questionIsFactLikeForHardFiltering = (question: GekanatorQuestion): boolean =>
question: GekanatorQuestion,
): boolean =>
!(question.kind === 'post_similarity' !(question.kind === 'post_similarity'
|| ( || (question.kind === 'tag'
question.kind === 'tag'
&& question.condition.type === 'tag' && question.condition.type === 'tag'
&& !(question.condition.key.startsWith ('nico:')))) && !(question.condition.key.startsWith ('nico:'))))
export const candidatePostsFor = ({ export const candidatePostsFor = (
posts, { posts,
questions, questions,
answers, answers,
softenedQuestionIds, softenedQuestionIds,
rejectedPostIds, rejectedPostIds,
recoveredCandidatePosts, recoveredCandidatePosts }: { posts: Post[]
}: { questions: GekanatorQuestion[]
posts: Post[] answers: GekanatorAnswerLog[]
questions: GekanatorQuestion[] softenedQuestionIds: Set<string>
answers: GekanatorAnswerLog[] rejectedPostIds: Set<number>
softenedQuestionIds: Set<string> recoveredCandidatePosts: Map<number, number> },
rejectedPostIds: Set<number> ): Post[] => {
recoveredCandidatePosts: Map<number, number>
}): Post[] => {
const questionById = new Map (questions.map (question => [question.id, question])) const questionById = new Map (questions.map (question => [question.id, question]))
return posts.filter (post => { return posts.filter (post => {
@@ -47,7 +37,7 @@ export const candidatePostsFor = ({
const answerCountAtRecovery = recoveredCandidatePosts.get (post.id) const answerCountAtRecovery = recoveredCandidatePosts.get (post.id)
return answers.every ((answer, index) => { return answers.every ((answer, index) => {
if (answerCountAtRecovery !== undefined && index < answerCountAtRecovery) if (answerCountAtRecovery != null && index < answerCountAtRecovery)
return true return true
if (softenedQuestionIds.has (answer.questionId)) if (softenedQuestionIds.has (answer.questionId))
@@ -62,10 +52,11 @@ export const candidatePostsFor = ({
switch (answer.answer) switch (answer.answer)
{ {
case 'yes': case 'yes':
case 'no': { case 'no':
const expected = expectedAnswerForQuestion (question, post) {
return expected === null || expected === 'unknown' || expected === answer.answer const expected = expectedAnswerForQuestion (question, post)
} return expected === null || expected === 'unknown' || expected === answer.answer
}
default: default:
return true return true
} }
@@ -74,15 +65,11 @@ export const candidatePostsFor = ({
} }
export const hardFilteredPostsForAnswer = ({ export const hardFilteredPostsForAnswer = (
posts, { posts, question, answer }: { posts: Post[]
question, question: GekanatorQuestion
answer, answer: GekanatorAnswerValue },
}: { ): Post[] => {
posts: Post[]
question: GekanatorQuestion
answer: GekanatorAnswerValue
}): Post[] => {
if (!(questionIsFactLikeForHardFiltering (question))) if (!(questionIsFactLikeForHardFiltering (question)))
return posts return posts
@@ -91,16 +78,12 @@ export const hardFilteredPostsForAnswer = ({
return posts.filter (post => { return posts.filter (post => {
const expected = expectedAnswerForQuestion (question, post) const expected = expectedAnswerForQuestion (question, post)
return expected === null || expected === 'unknown' || expected === answer return expected == null || expected === 'unknown' || expected === answer
}) })
} }
const concreteAnswerOptions: GekanatorAnswerValue[] = [ const concreteAnswerOptions: GekanatorAnswerValue[] = ['yes', 'no', 'partial', 'probably_no']
'yes',
'no',
'partial',
'probably_no']
export const allConcreteAnswerOptionsExhausted = ( export const allConcreteAnswerOptionsExhausted = (
@@ -119,45 +102,39 @@ const nextRecoveryTargetSize = (recoveryStepCount: number): number =>
6 * (2 ** recoveryStepCount) 6 * (2 ** recoveryStepCount)
export const recoverCandidatePosts = ({ export const recoverCandidatePosts = (
posts, { posts,
scores, scores,
rejectedPostIds, rejectedPostIds,
recoveredCandidatePosts, recoveredCandidatePosts,
eligiblePostIds, eligiblePostIds,
answerCountAtRecovery, answerCountAtRecovery,
recoveryStepCount, recoveryStepCount }: { posts: Post[]
}: { scores: Map<number, number>
posts: Post[] rejectedPostIds: Set<number>
scores: Map<number, number> recoveredCandidatePosts: Map<number, number>
rejectedPostIds: Set<number> eligiblePostIds: Set<number>
recoveredCandidatePosts: Map<number, number> answerCountAtRecovery: number
eligiblePostIds: Set<number> recoveryStepCount: number },
answerCountAtRecovery: number ): { recoveredCandidatePosts: Map<number, number>
recoveryStepCount: number recoveryStepCount: number } | null => {
}): {
recoveredCandidatePosts: Map<number, number>
recoveryStepCount: number
} | null => {
const recovered = new Map (recoveredCandidatePosts) const recovered = new Map (recoveredCandidatePosts)
const targetSize = nextRecoveryTargetSize (recoveryStepCount) const targetSize = nextRecoveryTargetSize (recoveryStepCount)
const countedPostIds = new Set ([ const countedPostIds = new Set ([...eligiblePostIds, ...recovered.keys ()])
...eligiblePostIds,
...recovered.keys ()])
const addCount = targetSize - countedPostIds.size const addCount = targetSize - countedPostIds.size
if (addCount <= 0) if (addCount <= 0)
return { {
recoveredCandidatePosts: recovered, return { recoveredCandidatePosts: recovered,
recoveryStepCount: recoveryStepCount + 1 } recoveryStepCount: recoveryStepCount + 1 }
}
const candidates = posts const candidates =
.filter (post => posts
!(rejectedPostIds.has (post.id)) .filter (post => (!(rejectedPostIds.has (post.id))
&& !(eligiblePostIds.has (post.id)) && !(eligiblePostIds.has (post.id))
&& !(recovered.has (post.id))) && !(recovered.has (post.id))))
.sort ((a, b) => .sort ((a, b) => ((scores.get (b.id) ?? Number.NEGATIVE_INFINITY)
(scores.get (b.id) ?? Number.NEGATIVE_INFINITY) - (scores.get (a.id) ?? Number.NEGATIVE_INFINITY)))
- (scores.get (a.id) ?? Number.NEGATIVE_INFINITY))
.slice (0, addCount) .slice (0, addCount)
if (candidates.length === 0) if (candidates.length === 0)
@@ -165,7 +142,6 @@ export const recoverCandidatePosts = ({
candidates.forEach (post => recovered.set (post.id, answerCountAtRecovery)) candidates.forEach (post => recovered.set (post.id, answerCountAtRecovery))
return { return { recoveredCandidatePosts: recovered,
recoveredCandidatePosts: recovered, recoveryStepCount: recoveryStepCount + 1 }
recoveryStepCount: recoveryStepCount + 1 }
} }
ファイル差分が大きすぎるため省略します 差分を読込み