()
| 111 | |
| 112 | |
| 113 | def main(): |
| 114 | ltp = LTP.from_pretrained("models/legacy") |
| 115 | ltp.add_word("姆去拿", 2) |
| 116 | words, pos, ner = ltp.pipeline("他叫汤姆去拿外衣。").to_tuple() |
| 117 | print(words, pos, ner) |
| 118 | pos, ner = ltp.pipeline(words, tasks=["pos", "ner"]).to_tuple() |
| 119 | print(pos, ner) |
| 120 | (ner,) = ltp.pipeline(words, pos, tasks=["ner"]).to_tuple() |
| 121 | print(ner) |
| 122 | |
| 123 | words, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。", "台湾是中国领土不可分割的一部分。"]).to_tuple() |
| 124 | print(words, pos, ner) |
| 125 | pos, ner = ltp.pipeline(words, tasks=["pos", "ner"]).to_tuple() |
| 126 | print(pos, ner) |
| 127 | (ner,) = ltp.pipeline(words, pos, tasks=["ner"]).to_tuple() |
| 128 | print(ner) |
| 129 | |
| 130 | |
| 131 | if __name__ == "__main__": |
no test coverage detected