ginic commited on
Commit
b3b1eee
·
1 Parent(s): 93cd88f

Updated example docstrings

Browse files
Files changed (1) hide show
  1. phone_distance.py +7 -2
phone_distance.py CHANGED
@@ -73,12 +73,12 @@ Returns:
73
  Examples:
74
  Compare articulatory differences in voicing in "bob" vs. "pop" and different pronunciations of "the":
75
  >>> phone_distance = evaluate.load("ginic/phone_distance")
76
- >>> phone_distance.compute(predictions=["bob", "θə"], references=["pop", "θi"])
77
  {'phone_error_rates': [0.6666666666666666, 0.5], 'mean_phone_error_rate': 0.5833333333333333, 'phone_feature_error_rates': [0.08333333333333333, 0.125], 'mean_phone_feature_error_rates': 0.10416666666666666, 'feature_error_rates': [0.027777777777777776, 0.0625], 'mean_feature_error_rates': 0.04513888888888889}
78
 
79
  Normalize PFER by the length of string with largest number of phones:
80
  >>> phone_distance = evaluate.load("ginic/phone_distance")
81
- >>> phone_distance.compute(predictions=["bob", "θə"], references=["pop", "θi"], is_normalize_pfer=True)
82
 
83
  """
84
 
@@ -91,6 +91,11 @@ def phone_error_rate(prediction:str, reference: str, distance_computer:panphon.d
91
 
92
  Returns:
93
  float: the phone error rate
 
 
 
 
 
94
  """
95
  if reference: # Can only be computed when the length of the reference greater than 0
96
  pred_phones = distance_computer.fm.ipa_segs(prediction)
 
73
  Examples:
74
  Compare articulatory differences in voicing in "bob" vs. "pop" and different pronunciations of "the":
75
  >>> phone_distance = evaluate.load("ginic/phone_distance")
76
+ >>> phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"])
77
  {'phone_error_rates': [0.6666666666666666, 0.5], 'mean_phone_error_rate': 0.5833333333333333, 'phone_feature_error_rates': [0.08333333333333333, 0.125], 'mean_phone_feature_error_rates': 0.10416666666666666, 'feature_error_rates': [0.027777777777777776, 0.0625], 'mean_feature_error_rates': 0.04513888888888889}
78
 
79
  Normalize PFER by the length of string with largest number of phones:
80
  >>> phone_distance = evaluate.load("ginic/phone_distance")
81
+ >>> phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"], is_normalize_pfer=True)
82
 
83
  """
84
 
 
91
 
92
  Returns:
93
  float: the phone error rate
94
+
95
+ >>> phone_error_rate("bob", "po", panphon.distance.Distance())
96
+ 1.0
97
+ >>> phone_error_rate("ði", "ðə", panphon.distance.Distance())
98
+ 0.5
99
  """
100
  if reference: # Can only be computed when the length of the reference greater than 0
101
  pred_phones = distance_computer.fm.ipa_segs(prediction)