Fix word_segment
Browse files
README.md
CHANGED
|
@@ -39,9 +39,9 @@ pipeline_tag: text-classification
|
|
| 39 |
|
| 40 |
|
| 41 |
## Installation
|
| 42 |
-
- Install `
|
| 43 |
|
| 44 |
-
- `pip install
|
| 45 |
|
| 46 |
- Install `sentence-transformers` (recommend) - [Usage](#usage-with-sentence-transformers):
|
| 47 |
|
|
@@ -54,7 +54,9 @@ pipeline_tag: text-classification
|
|
| 54 |
## Pre-processing
|
| 55 |
|
| 56 |
```python
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
|
| 59 |
query = "Trường UIT là gì?"
|
| 60 |
sentences = [
|
|
@@ -63,8 +65,8 @@ sentences = [
|
|
| 63 |
"Quĩ uỷ thác đầu tư (tiếng Anh: Unit Investment Trusts; viết tắt: UIT) là một công ty đầu tư mua hoặc nắm giữ một danh mục đầu tư cố định"
|
| 64 |
]
|
| 65 |
|
| 66 |
-
tokenized_query =
|
| 67 |
-
tokenized_sentences = [
|
| 68 |
|
| 69 |
tokenized_pairs = [[tokenized_query, sent] for sent in tokenized_sentences]
|
| 70 |
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
## Installation
|
| 42 |
+
- Install `VnCoreNLP` to word segment:
|
| 43 |
|
| 44 |
+
- `pip install py_vncorenlp`
|
| 45 |
|
| 46 |
- Install `sentence-transformers` (recommend) - [Usage](#usage-with-sentence-transformers):
|
| 47 |
|
|
|
|
| 54 |
## Pre-processing
|
| 55 |
|
| 56 |
```python
|
| 57 |
+
import py_vncorenlp
|
| 58 |
+
py_vncorenlp.download_model(save_dir='/absolute/path/to/vncorenlp')
|
| 59 |
+
rdrsegmenter = py_vncorenlp.VnCoreNLP(annotators=["wseg"], save_dir='/absolute/path/to/vncorenlp')
|
| 60 |
|
| 61 |
query = "Trường UIT là gì?"
|
| 62 |
sentences = [
|
|
|
|
| 65 |
"Quĩ uỷ thác đầu tư (tiếng Anh: Unit Investment Trusts; viết tắt: UIT) là một công ty đầu tư mua hoặc nắm giữ một danh mục đầu tư cố định"
|
| 66 |
]
|
| 67 |
|
| 68 |
+
tokenized_query = rdrsegmenter.word_segment(query)
|
| 69 |
+
tokenized_sentences = [rdrsegmenter.word_segment(sent) for sent in sentences]
|
| 70 |
|
| 71 |
tokenized_pairs = [[tokenized_query, sent] for sent in tokenized_sentences]
|
| 72 |
|