Skip to content

Commit 1accbd6

Browse files
authored
Update readme
1 parent a3a4cc1 commit 1accbd6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Readme.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,27 @@ _Assume that the Python wrapper of VnCoreNLP is already installed via: ``$ pip3
4444

4545
1. Run the following command:
4646

47-
``$ vncorenlp -Xmx2g <VnCoreNLP-jar-file-path> -p 9000 -a "wseg,pos,ner,parse"``
47+
``$ vncorenlp -Xmx2g <FULL-PATH-to-VnCoreNLP-jar-file> -p 9000 -a "wseg,pos,ner,parse"``
4848

4949
The service is now available at ``http://127.0.0.1:9000``.
5050

5151
2. Use the service in your `python` code:
5252

5353
```python
5454
from vncorenlp import VnCoreNLP
55-
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
5655
annotator = VnCoreNLP(address="http://127.0.0.1", port=9000)
57-
annotated_text = annotator.annotate(text) # json format
5856

59-
# If you want to use only the word segmenter
57+
# Input
58+
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
59+
60+
# To perform word segmentation, POS tagging, NER and then dependency parsing
61+
annotated_text = annotator.annotate(text)
62+
63+
# To perform word segmentation only
6064
word_segmented_text = annotator.tokenize(text)
6165
```
6266

63-
- `print(annotated_text)`
67+
- `print(annotated_text)` # JSON format
6468

6569
```
6670
{'sentences': [[{'index': 1, 'form': 'Ông', 'posTag': 'Nc', 'nerLabel': 'O', 'head': 4, 'depLabel': 'sub'}, {'index': 2, 'form': 'Nguyễn_Khắc_Chúc', 'posTag': 'Np', 'nerLabel': 'B-PER', 'head': 1, 'depLabel': 'nmod'}, {'index': 3, 'form': 'đang', 'posTag': 'R', 'nerLabel': 'O', 'head': 4, 'depLabel': 'adv'}, {'index': 4, 'form': 'làm_việc', 'posTag': 'V', 'nerLabel': 'O', 'head': 0, 'depLabel': 'root'}, {'index': 5, 'form': 'tại', 'posTag': 'E', 'nerLabel': 'O', 'head': 4, 'depLabel': 'loc'}, {'index': 6, 'form': 'Đại_học', 'posTag': 'N', 'nerLabel': 'B-ORG', 'head': 5, 'depLabel': 'pob'}, {'index': 7, 'form': 'Quốc_gia', 'posTag': 'N', 'nerLabel': 'I-ORG', 'head': 6, 'depLabel': 'nmod'}, {'index': 8, 'form': 'Hà_Nội', 'posTag': 'Np', 'nerLabel': 'I-ORG', 'head': 6, 'depLabel': 'nmod'}, {'index': 9, 'form': '.', 'posTag': 'CH', 'nerLabel': 'O', 'head': 4, 'depLabel': 'punct'}], [{'index': 1, 'form': 'Bà', 'posTag': 'Nc', 'nerLabel': 'O', 'head': 9, 'depLabel': 'sub'}, {'index': 2, 'form': 'Lan', 'posTag': 'Np', 'nerLabel': 'B-PER', 'head': 1, 'depLabel': 'nmod'}, {'index': 3, 'form': ',', 'posTag': 'CH', 'nerLabel': 'O', 'head': 1, 'depLabel': 'punct'}, {'index': 4, 'form': 'vợ', 'posTag': 'N', 'nerLabel': 'O', 'head': 1, 'depLabel': 'nmod'}, {'index': 5, 'form': 'ông', 'posTag': 'Nc', 'nerLabel': 'O', 'head': 4, 'depLabel': 'nmod'}, {'index': 6, 'form': 'Chúc', 'posTag': 'Np', 'nerLabel': 'B-PER', 'head': 5, 'depLabel': 'nmod'}, {'index': 7, 'form': ',', 'posTag': 'CH', 'nerLabel': 'O', 'head': 1, 'depLabel': 'punct'}, {'index': 8, 'form': 'cũng', 'posTag': 'R', 'nerLabel': 'O', 'head': 9, 'depLabel': 'adv'}, {'index': 9, 'form': 'làm_việc', 'posTag': 'V', 'nerLabel': 'O', 'head': 0, 'depLabel': 'root'}, {'index': 10, 'form': 'tại', 'posTag': 'E', 'nerLabel': 'O', 'head': 9, 'depLabel': 'loc'}, {'index': 11, 'form': 'đây', 'posTag': 'P', 'nerLabel': 'O', 'head': 10, 'depLabel': 'pob'}, {'index': 12, 'form': '.', 'posTag': 'CH', 'nerLabel': 'O', 'head': 9, 'depLabel': 'punct'}]]}
@@ -79,11 +83,9 @@ word_segmented_text = annotator.tokenize(text)
7983

8084
```python
8185
from vncorenlp import VnCoreNLP
86+
annotator = VnCoreNLP("<FULL-PATH-to-VnCoreNLP-jar-file>")
8287
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
83-
annotator = VnCoreNLP("<VnCoreNLP-jar-file-path>")
84-
annotated_text = annotator.annotate(text) # json format
85-
86-
# If you want to use only the word segmenter
88+
annotated_text = annotator.annotate(text)
8789
word_segmented_text = annotator.tokenize(text)
8890

8991
```
@@ -97,7 +99,7 @@ _For more details, we refer users to [https://github.com/dnanhkhoa/python-vncore
9799

98100
You can run VnCoreNLP to annotate an input raw text corpus (e.g. a collection of news content) by using following commands:
99101

100-
//To perform word segmentation, POS tagging, NER and then dependency parsing
102+
// To perform word segmentation, POS tagging, NER and then dependency parsing
101103
$ java -Xmx2g -jar VnCoreNLP-1.1.jar -fin input.txt -fout output.txt
102104
// To perform word segmentation, POS tagging and then NER
103105
$ java -Xmx2g -jar VnCoreNLP-1.1.jar -fin input.txt -fout output.txt -annotators wseg,pos,ner

0 commit comments

Comments
 (0)