1from transformers import pipeline
2import torch
3from datasets import load_dataset
4
5
6pipe = pipeline("token-classification", model="no-name-research/camembert-token-classification", aggregation_strategy="simple", device=device)
7
8content = "* ALBI, (Géog.) ville de France, capitale de l'Albigeois, dans le haut Languedoc : elle est sur le Tarn. Long. 19. 49. lat. 43. 55. 44."
9
10print(pipe(content))
11
12
13# Output
14[{'entity_group': 'Head',
15 'score': 0.9918331,
16 'word': 'ALBI',
17 'start': 2,
18 'end': 6},
19 {'entity_group': 'Domain_mark',
20 'score': 0.9260238,
21 'word': '(Géog.',
22 'start': 8,
23 'end': 14},
24 {'entity_group': 'NC_Spatial',
25 'score': 0.99029493,
26 'word': 'ville',
27 'start': 16,
28 'end': 21},
29 {'entity_group': 'NP_Spatial',
30 'score': 0.9919335,
31 'word': 'France',
32 'start': 25,
33 'end': 31},
34 {'entity_group': 'NC_Spatial',
35 'score': 0.9903319,
36 'word': 'capitale',
37 'start': 33,
38 'end': 41},
39 {'entity_group': 'NP_Spatial',
40 'score': 0.9919644,
41 'word': "l'Albigeois",
42 'start': 45,
43 'end': 56},
44 {'entity_group': 'Relation',
45 'score': 0.98715705,
46 'word': 'dans',
47 'start': 58,
48 'end': 62},
49 {'entity_group': 'NP_Spatial',
50 'score': 0.9919502,
51 'word': 'le haut Languedoc',
52 'start': 63,
53 'end': 80},
54 {'entity_group': 'Relation',
55 'score': 0.98698694,
56 'word': 'sur',
57 'start': 92,
58 'end': 95},
59 {'entity_group': 'NP_Spatial',
60 'score': 0.9921453,
61 'word': 'le Tarn',
62 'start': 96,
63 'end': 103},
64 {'entity_group': 'Latlong',
65 'score': 0.99200517,
66 'word': 'Long. 19. 49. lat. 43. 55. 44',
67 'start': 105,
68 'end': 134}]