Moved a var
This commit is contained in:
@@ -5,6 +5,7 @@ export const regexWikilink = /^!?\[\[(?<name>.+?)(\|(?<alias>.+?))?\]\]/
|
|||||||
export const regexLineSplit = /\r?\n|\r|((\.|\?|!)( |\r?\n|\r))/g
|
export const regexLineSplit = /\r?\n|\r|((\.|\?|!)( |\r?\n|\r))/g
|
||||||
export const regexYaml = /^---\s*\n(.*?)\n?^---\s?/ms
|
export const regexYaml = /^---\s*\n(.*?)\n?^---\s?/ms
|
||||||
export const regexStripQuotes = /^"|"$|^'|'$/g
|
export const regexStripQuotes = /^"|"$|^'|'$/g
|
||||||
|
export const chsRegex = /[\u4e00-\u9fa5]/
|
||||||
|
|
||||||
export const excerptBefore = 100
|
export const excerptBefore = 100
|
||||||
export const excerptAfter = 180
|
export const excerptAfter = 180
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Notice, TFile, type TAbstractFile } from 'obsidian'
|
import { Notice, TFile, type TAbstractFile } from 'obsidian'
|
||||||
import MiniSearch, { type SearchResult } from 'minisearch'
|
import MiniSearch, { type SearchResult } from 'minisearch'
|
||||||
import {
|
import {
|
||||||
|
chsRegex,
|
||||||
SPACE_OR_PUNCTUATION,
|
SPACE_OR_PUNCTUATION,
|
||||||
type IndexedNote,
|
type IndexedNote,
|
||||||
type ResultNote,
|
type ResultNote,
|
||||||
@@ -17,15 +18,13 @@ import type { Query } from './query'
|
|||||||
let minisearchInstance: MiniSearch<IndexedNote>
|
let minisearchInstance: MiniSearch<IndexedNote>
|
||||||
let indexedNotes: Record<string, IndexedNote> = {}
|
let indexedNotes: Record<string, IndexedNote> = {}
|
||||||
|
|
||||||
const chsPattern = /[\u4e00-\u9fa5]/
|
|
||||||
|
|
||||||
const tokenize = (text: string): string[] => {
|
const tokenize = (text: string): string[] => {
|
||||||
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
||||||
const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
||||||
|
|
||||||
if (chsSegmenter) {
|
if (chsSegmenter) {
|
||||||
return tokens.flatMap(word =>
|
return tokens.flatMap(word =>
|
||||||
chsPattern.test(word) ? chsSegmenter.cut(word) : [word],
|
chsRegex.test(word) ? chsSegmenter.cut(word) : [word],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else return tokens
|
else return tokens
|
||||||
|
|||||||
Reference in New Issue
Block a user