Skip to content

Commit

Permalink
✨ Add join chunk feature to labeling model.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrikerMan committed May 22, 2019
1 parent fd9ef4d commit 476132f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kashgari/tasks/labeling/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def get_default_hyper_parameters(cls) -> Dict[str, Dict[str, Any]]:
def predict_entities(self,
x_data,
batch_size=None,
join_chunk=' ',
debug_info=False):
"""Gets entities from sequence.
Args:
x_data: The input data, as a Numpy array (or list of Numpy arrays if the model has multiple inputs).
batch_size: Integer. If unspecified, it will default to 32.
join_chunk: str or False,
debug_info: Bool, Should print out the logging info.
Returns:
Expand All @@ -61,11 +63,16 @@ def predict_entities(self,
for index, seq in enumerate(new_res):
seq_data = []
for entity in seq:
if join_chunk is False:
value = x_data[index][entity[1]:entity[2] + 1],
else:
value = join_chunk.join(x_data[index][entity[1]:entity[2] + 1])

seq_data.append({
"entity": entity[0],
"start": entity[1],
"end": entity[2],
"value": x_data[index][entity[1]:entity[2] + 1],
"value": value,
})
final_res.append(seq_data)
return final_res
Expand Down

0 comments on commit 476132f

Please sign in to comment.