brief: | i18n.site tsopano imathandizira kusaka kwamalemba athunthu opanda seva.

Nkhaniyi ikuwonetsa kukhazikitsidwa kwaukadaulo waukadaulo wamawu akutsogolo, kuphatikiza indexedDB yopangidwa ndi indexedDB, kusaka kwachiyambi, kukhathamiritsa kwa magawo a mawu komanso kuthandizira zilankhulo zambiri.

Poyerekeza ndi mayankho omwe alipo, kusaka koyera kutsogolo kwa i18n.site ndikocheperako komanso mwachangu, koyenera mawebusayiti ang'onoang'ono ndi apakatikati monga zolemba ndi mabulogu, ndipo amapezeka popanda intaneti.


Kusaka Kolondola Kwa Mawu Athunthu

Ndandanda

& pa chitukuko cha masabata angapo markdown i18n.site

Nkhaniyi igawana zaukadaulo wa i18n.site kusaka kwathunthu-kumapeto i18n.site kuti mumve zakusaka.

Khodi gwero : fufuzani kernel / yolumikizirana

Ndemanga Ya Mayankho Osakira Mawu Opanda Seva

Kwa mawebusayiti ang'onoang'ono ndi apakatikati omwe ali ngati zikalata / mabulogu anu, kupanga zolemba zodzipangira nokha ndizolemera kwambiri, ndipo kusaka mawu athunthu kopanda ntchito ndikomwe kofala.

Mayankho osakira mawu opanda seva amagwera m'magulu awiri:

Choyamba, ofanana algolia.com

Ntchito zotere zimafunikira kulipira kutengera kuchuluka kwakusaka, ndipo nthawi zambiri sapezeka kwa ogwiritsa ntchito ku China chifukwa chazovuta monga kutsata tsamba lawebusayiti.

Sichingagwiritsidwe ntchito pa intaneti, sichingagwiritsidwe ntchito pa intaneti, ndipo chili ndi malire aakulu. Nkhaniyi sifotokoza zambiri.

Chachiwiri ndikufufuza mawu athunthu.

Pakadali pano, kusaka kodziwika lunrjs komaliza kumaphatikizapo ElasticLunr.js (kutengera chitukuko lunrjs ).

lunrjs Pali njira ziwiri zopangira ma index, ndipo onse ali ndi zovuta zawo.

  1. Mafayilo opangidwa kale

    Chifukwa mlozerawu uli ndi mawu ochokera m'malemba onse, ndi wamkulu mu kukula kwake. Nthawi zonse chikalata chiwonjezedwa kapena kusinthidwa, fayilo yatsopano ya index iyenera kukwezedwa. Idzawonjezera nthawi yodikira ya wogwiritsa ntchito ndikuwononga bandwidth yambiri.

  2. Kwezani zikalata ndi kupanga indexes pa ntchentche

    Kupanga index ndi ntchito yovuta kwambiri yomanganso index nthawi iliyonse mukafika kumapangitsa kuti pakhale kusakhazikika komanso kusazindikira bwino kwa ogwiritsa ntchito.


Kuphatikiza pa lunrjs , palinso mayankho ena athunthu, monga :

fusejs , werengerani kufanana pakati pa zingwe kuti mufufuze.

Magwiridwe a yankholi ndiwoyipa kwambiri ndipo sangathe kugwiritsidwa ntchito posaka mawu athunthu (onani Fuse.js Kufunsa kwautali kumatenga kupitilira masekondi 10 , mungakulitsitse bwanji? ).

TinySearch , gwiritsani ntchito fyuluta ya Bloom kuti mufufuze, siingagwiritsidwe ntchito pakusaka kwachiyambi (mwachitsanzo, lowetsani goo , fufuzani good , google ), ndipo simungathe kukwaniritsa zotsatira zofananazo.

Chifukwa cha zolakwika za mayankho omwe alipo, i18n.site adapanga njira yatsopano yosakira mawu, yomwe ili ndi zotsatirazi :

  1. Imathandizira kusaka kwa zinenero zambiri ndipo ndi yaying'ono mu kukula kwa kernel yofufuzira pambuyo pa kulongedza gzip ndi 6.9KB (poyerekeza, kukula kwa lunrjs ndi 25KB )
  2. Pangani index inverted yochokera ku indexedb , yomwe imatenga kukumbukira pang'ono komanso mwachangu.
  3. Zolemba zikawonjezeredwa / kusinthidwa, zolemba zokha zowonjezera kapena zosinthidwa zimasinthidwanso, kuchepetsa kuchuluka kwa mawerengedwe.
  4. Imathandizira kusaka kwachiyambi ndipo imatha kuwonetsa zotsatira zake munthawi yeniyeni pomwe wogwiritsa ntchito akulemba.
  5. Ikupezeka popanda intaneti

Pansipa, i18n.site tsatanetsatane waukadaulo waukadaulo adzafotokozedwa mwatsatanetsatane.

Kugawa Mawu Azilankhulo Zambiri

Kugawanika kwa mawu kumagwiritsa ntchito gawo la mawu a msakatuli Intl.Segmenter , ndipo asakatuli onse akuluakulu amathandizira mawonekedwe awa.

Mawu akuti segmentation coffeescript code ali motere

SEG = new Intl.Segmenter 0, granularity: "word"

seg = (txt) =>
  r = []
  for {segment} from SEG.segment(txt)
    for i from segment.split('.')
      i = i.trim()
      if i and !'| `'.includes(i) and !/\p{P}/u.test(i)
        r.push i
  r

export default seg

export segqy = (q) =>
  seg q.toLocaleLowerCase()

mu: