Skip to content

Commit

Permalink
build err fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uxiun committed Nov 4, 2023
1 parent 5fcbdc1 commit 993c0b4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
29 changes: 16 additions & 13 deletions pages/TextRewriter/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from "@mui/material"
import EditIcon from "@mui/icons-material/Edit"
import { useAtom } from "jotai"
import React, { FC, ReactEventHandler, useEffect, useMemo, useState } from "react"
import React, { FC, ReactEventHandler, useCallback, useEffect, useMemo, useState } from "react"
import RecycleForm from "./recycleForm"
import { concernLength, ngramScoreMap } from "@/ts/ts/text"
import { caseUndefined, mapUnions, mapUnionsToAverage } from "@/ts/ts/map"
Expand Down Expand Up @@ -88,27 +88,30 @@ const SimilarEntries: FC<SimilarEntriesProp> = prop => {

const lengthmaps = getLengthMap(atomEntryIdDedupedMap, atomDedupedMap)

const ngramScoreMap_concernLength = (fromto: keyof FromToObj) =>
concernLength(
mapUnionsToAverage(
atomIndex[fromto].map(index => {
const ngramScored = ngramScoreMap(index)(inputting[fromto])
// console.log(`ngramScored${index.n}`, ngramScored)
return ngramScored
})
)
)(inputting[fromto].length, lengthmaps[fromto])
const ngramScoreMap_concernLength = useCallback(
(fromto: keyof FromToObj) =>
concernLength(
mapUnionsToAverage(
atomIndex[fromto].map(index => {
const ngramScored = ngramScoreMap(index)(inputting[fromto])
// console.log(`ngramScored${index.n}`, ngramScored)
return ngramScored
})
)
)(inputting[fromto].length, lengthmaps[fromto]),
[atomIndex]
)

const similarfrom = useMemo(() => {
// console.log("atom index", atomIndex)
const scored = ngramScoreMap_concernLength("from")
// console.log("scored", scored)
return [...scored.entries()].sort((d, f) => f[1] - d[1]).slice(0, prop.maxShowNumber)
}, [allentries, inputting.from])
}, [ngramScoreMap_concernLength, prop.maxShowNumber])
const similarto = useMemo(() => {
const scored = ngramScoreMap_concernLength("to")
return [...scored.entries()].sort((d, f) => f[1] - d[1]).slice(0, prop.maxShowNumber)
}, [allentries, inputting.to, inputting.from])
}, [ngramScoreMap_concernLength, prop.maxShowNumber])

const similarCalc = {
from: similarfrom,
Expand Down
10 changes: 9 additions & 1 deletion pages/TextRewriter/entryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ const EntryForm: FC = () => {
}
// }, 100)
// return () => clearTimeout(debounce)
}, [useWatchValue, allentries])
}, [
useWatchValue,
allentries,
dedupedEntryMap,
lang,
newForm,
setatomInputtingEntry,
setatomMatchingEntry,
])
const addEntry = (f: Form) => {
const { to, ...fkey } = f
const key = JSON.stringify(fkey)
Expand Down
4 changes: 3 additions & 1 deletion pages/TextRewriter/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const InfoComponent: FC = () => {
</Button>
</div>
<div>
{show ? [...Object.entries(translationTree.info)].map(o => <p>{o[1][lang]}</p>) : ""}{" "}
{show
? [...Object.entries(translationTree.info)].map((o, i) => <p key={i}>{o[1][lang]}</p>)
: ""}{" "}
</div>
</div>
)
Expand Down
10 changes: 9 additions & 1 deletion pages/TextRewriter/recycleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ const RecycleForm: FC<RecycleFormProp> = prop => {
setAddButtonContent("add")
setatomMatchingEntry(newe)
}
}, [useWatchValue, allentries])
}, [
useWatchValue,
allentries,
dedupedEntryMap,
lang,
newForm,
setatomInputtingEntry,
setatomMatchingEntry,
])

const addEntry = (f: Form) => {
// console.log("addEntry called")
Expand Down
2 changes: 1 addition & 1 deletion pages/TextRewriter/searchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SearchForm: FC = () => {

useEffect(() => {
setAtomSearchDelay(useWatchValue.delay ?? defaultSimilarForm.delay)
}, [useWatchValue])
}, [useWatchValue, setAtomSearchDelay])

return (
<Box>
Expand Down

0 comments on commit 993c0b4

Please sign in to comment.