leizongmin / leizongmin/node-segment
同义词替换无法保留原始内容结构,空格、换行丢失
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 132
- PR merge metrics
- No merged PRs in 30d
Description
我想要对一篇文章实现一个简单的同义词替换,但是我使用以下方式,一些空格和换行会丢失
const text = fs.readFileSync('file.txt', 'utf8');
const result = segment.doSegment(text, {
convertSynonym: true,
simple: true
})
console.info(`finish with result: ${result.join('')}`)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using fs.readFileSync and segment.doSegment with convertSynonym and simple enabled, then inspect how the returned result is joined. Verify that synonym replacement preserves the input's spaces and newlines, and use the provided example to confirm the original structure remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100