Views
No views yet
1from transformers import pipeline
2
3ner = pipeline(
4 "ner",
5 model="fahmisyaifudin/indobert_ner_p1",
6 tokenizer="fahmisyaifudin/indobert_ner_p1",
7 aggregation_strategy="simple"
8)
9
10text = "Hadiri KTT G20, Momen Gibran Bersama Erdogan hingga PM Jepang"
11entities = ner(text)
12
13print(entities)
14# Output: [{'entity_group': 'EVENT', 'score': np.float32(0.9938912), 'word': 'ktt g20', 'start': 7, 'end': 14}, {'entity_group': 'PERSON', 'score': np.float32(0.80416846), 'word': 'gibran', 'start': 22, 'end': 28}, {'entity_group': 'PERSON', 'score': np.float32(0.99820226), 'word': 'erdogan', 'start': 37, 'end': 44}, {'entity_group': 'REPRESENTATIVE_PERSON', 'score': np.float32(0.9186572), 'word': 'pm jepang', 'start': 52, 'end': 61}]