rules module

rules.check_length(ref, generated)
rules.check_pingze(ref, generated, vocab_lookup, tone_lookup)
rules.check_rules_based_on_pingze(cir_tone, matched_rules)

check the tone of reference ci w.r.t matched_rules

Parameters:
  • cir_tone (list of list) – the tone information for the referenced ci
  • matched_rules (list of list of list) – the list of rules given the title,corresponding to number of lines and length of each lines
Returns:

the best matched rule and corresponding score

Return type:

list of list,float

rules.check_yunshe(random_yunjiao, generated, vocab_lookup, vowel_lookup)
rules.find_potential_rules_by_title(rules, cir)
find the rules that has same number of lines and
each line has same length of chars
Parameters:
  • rules (list of list of list) – all rules w.r.t the specific title
  • cir (list of list) – the reference of ci which is already encoded
Returns:

matched_rules

Return type:

list of list of list

rules.get_yunjiao_training(rules, cir_ids, cir_tone, cir_vowel)
same as above except for training
current under development
Parameters:
  • rules
  • cir_ids
  • cir_tone
  • cir_vowel
Returns:

Return type:

rules.group_yunshe(rule, cir, cir_vowel)
get yunjiao by group, rule can be specified or not, if not, we assume
the position of yunjiao is before any in rule_known_punctuation

:param rule:the best matched rule or not given :type rule: list of list or empty list :param cir: the referenced ci which is already encoded :type cir: list of list :param cir_vowel: the encoded vowel info for referenced ci :type cir_vowel: list of list :return: group yunshe with corresponding line index :rtype: dict

rules.pz_mapping(x)

mapping vocal character to id

Parameters:x (char) – vocal character in rule
Returns:id w.r.t to x
Return type:int
rules.random_yunjiao(yunjiao, cuml)

assign random yunshe to yunjiao position

Parameters:
  • yunjiao (dict) – origin yunjiao info group by yunshe
  • cuml (list of int) – cumulative interval
Returns:

random_yunjiao after assign

Return type:

dict

rules.random_yunshe(cuml, drawn)

generate yunshe randomly

Parameters:
  • cuml (list of int) – cumulative interval
  • drawn (int) – a int drawn form the whole range
Returns:

random_yunshe

Return type:

int

rules.yunshe_statistics(vowel_dict)

cumulative interval based on vowel info from the whole corpus

Parameters:vowel_dict (dict of list of list of list) – vowel info for the whole corpus
Returns:cumulative interval
Return type:list of int