-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds support for Japanese language (#653)
- Loading branch information
1 parent
33c5dde
commit ef6106a
Showing
23 changed files
with
1,186 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/docs/open-source/supported-languages/using-japanese-with-orama.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Using Japanese with Orama | ||
|
||
At the time of writing, Orama supports Japanese via a custom tokenizer, which is part of the `@orama/tokenizers` package. | ||
|
||
:::warning | ||
The Japanese tokenizer is a compiled WASM from the [lindera](https://github.com/lindera-morphology/lindera) Rust project. | ||
It can be quite large and its usage on the browser is discouraged. | ||
::: | ||
|
||
To get started, make sure to install all the dependencies you need: | ||
|
||
```sh | ||
npm i @orama/orama @orama/tokenizers | ||
``` | ||
|
||
If you want to add Japanese stop-words as well, install the `@orama/stopwords` package too: | ||
|
||
```sh | ||
npm i @orama/stopwords | ||
``` | ||
|
||
Now you're ready to get started with Orama: | ||
|
||
```js | ||
import { create, insert, search } from '@orama/orama' | ||
import { createTokenizer } from '@orama/tokenizers' | ||
import { stopwords as japaneseStopwords } from '@orama/stopwords/japanese' | ||
|
||
const db = await create({ | ||
schema: { | ||
name: 'string' | ||
}, | ||
components: { | ||
tokenizer: await createTokenizer({ | ||
stopWords: japaneseStopwords | ||
}) | ||
} | ||
}) | ||
|
||
await insert(db, { name: '東京' }) // Tokyo | ||
await insert(db, { name: '大阪' }) // Osaka | ||
await insert(db, { name: '京都' }) // Kyoto | ||
await insert(db, { name: '横浜' }) // Yokohama | ||
await insert(db, { name: '札幌' }) // Sapporo | ||
await insert(db, { name: '仙台' }) // Sendai | ||
await insert(db, { name: '広島' }) // Hiroshima | ||
await insert(db, { name: '東京大学' }) // University of Tokyo | ||
await insert(db, { name: '京都大学' }) // Kyoto University | ||
await insert(db, { name: '大阪大学' }) // Osaka University | ||
|
||
const results = await search(db, { | ||
term: '大阪', | ||
threshold: 0 | ||
}) | ||
|
||
console.log(results) | ||
|
||
// { | ||
// "elapsed": { | ||
// "raw": 89554625, | ||
// "formatted": "89ms" | ||
// }, | ||
// "hits": [ | ||
// { | ||
// "id": "36666208-3", | ||
// "score": 4.210224897276653, | ||
// "document": { | ||
// "name": "大阪" | ||
// } | ||
// }, | ||
// { | ||
// "id": "36666208-10", | ||
// "score": 1.9335268122510698, | ||
// "document": { | ||
// "name": "大阪大学" | ||
// } | ||
// } | ||
// ], | ||
// "count": 2 | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
pkg |
Oops, something went wrong.