syubraj commited on
Commit
fa18a9b
·
verified ·
1 Parent(s): f7c6583

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -24
README.md CHANGED
@@ -67,41 +67,28 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
67
 
68
  # Define the custom label mapping
69
  custom_label_mapping = {
70
- 0: 'O', # Outside of any named entity
71
- 1: 'B-PER', # Beginning of a person's name
72
- 2: 'I-PER', # Inside a person's name
73
- 3: 'B-ORG', # Beginning of an organization's name
74
- 4: 'I-ORG', # Inside an organization's name
75
- 5: 'B-LOC', # Beginning of a location's name
76
- 6: 'I-LOC', # Inside a location's name
77
  }
78
 
79
  ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
80
 
81
- # Input text
82
- text = "Donald trabaja en Twitter"
83
 
84
  raw_results = ner_pipeline(text)
85
 
86
- results_with_labels = []
87
  for entity in raw_results:
88
  label_index = int(entity['entity'].split('_')[1])
89
 
90
  entity_label = custom_label_mapping.get(label_index, "UNKNOWN")
91
-
92
- entity_with_label = {
93
- "entity": entity_label, # Use the mapped label
94
- "word": entity["word"],
95
- "start": entity["start"],
96
- "end": entity["end"],
97
- "score": entity["score"],
98
- }
99
- results_with_labels.append(entity_with_label)
100
-
101
- # Print the final results
102
- print("NER Results Labels:")
103
- for result in results_with_labels:
104
- print(result)
105
  ```
106
 
107
  ## Training procedure
 
67
 
68
  # Define the custom label mapping
69
  custom_label_mapping = {
70
+ 0: 'O',
71
+ 1: 'B-PER',
72
+ 2: 'I-PER',
73
+ 3: 'B-ORG',
74
+ 4: 'I-ORG',
75
+ 5: 'B-LOC',
76
+ 6: 'I-LOC',
77
  }
78
 
79
  ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
80
 
81
+ # Sample Spanish text
82
+ text = "Elon Musk vive en Estados Unidos y es dueño de Space X, Tesla y Starlink"
83
 
84
  raw_results = ner_pipeline(text)
85
 
 
86
  for entity in raw_results:
87
  label_index = int(entity['entity'].split('_')[1])
88
 
89
  entity_label = custom_label_mapping.get(label_index, "UNKNOWN")
90
+ print(f"Word: {entity['word']}, Label: {entity_label}")
91
+
 
 
 
 
 
 
 
 
 
 
 
 
92
  ```
93
 
94
  ## Training procedure