private Mx.bitbase <enrWORD> .table_row Split_WordList(string ur_input) { var ret_words = new Mx.bitbase <enrWORD> .table_row(); if (ur_input.Length == 0) { ret_words.Persist_Read(@"C:\Users\Dad\Downloads\2021m10d31 ASLSJ Parse\SampleData.tsv"); foreach (var row in ret_words) { row[enrWORD.word] = row[enrWORD.word].Replace(char.ConvertFromUtf32(8211).ToString(), "--").Trim(); } } else { foreach (var entry in ur_input.Split('\n')) { if (string.IsNullOrWhiteSpace(entry) == false) { ret_words.add_row()[enrWORD.word] = entry.Replace(char.ConvertFromUtf32(8211).ToString(), "--").Trim(); } } } return(ret_words); }
void Append_Syll( ref int ref_syll_seq, System.Text.StringBuilder ur_stp_syll, enrSYLL_DSCR ur_syll_dscr, Mx.bitbase <enrSYLL> .table_row ur_sylls, Mx.bitbase <enrWORD> .row_enum ur_word_rec) { if (ur_stp_syll.Length > 0) { var last_syll = ur_sylls.add_row(); ref_syll_seq += 1; last_syll[enrSYLL.word] = ur_word_rec[enrWORD.word]; last_syll[enrSYLL.syll_seq] = ref_syll_seq.ToString(); last_syll[enrSYLL.syll_text] = ur_stp_syll.ToString(); last_syll[enrSYLL.syll_dscr] = ur_syll_dscr.pname; ur_stp_syll.Clear(); } }
bool Append_Syll( char ur_entry, enrSYLL_STATE ur_test_syll, enrSYLL_DSCR flag_new_syll, ref enrSYLL_STATE ref_cur_state, ref int ref_syll_seq, System.Text.StringBuilder ur_stp_syll, Mx.bitbase <enrSYLL> .table_row ur_sylls, Mx.bitbase <enrWORD> .row_enum ur_word_rec, System.Collections.Generic.List <SyllCode> ur_syll_codes) { var ret_is_syll = false; foreach (var entry in ur_syll_codes) { if (ur_test_syll == entry.cur_state) { if (ur_entry == entry.syll_char || entry.syll_char == '*') { ret_is_syll = true; } } } if (ret_is_syll || ur_test_syll == enrSYLL_STATE.word_end) { if (flag_new_syll != enrSYLL_DSCR.incomplete) { ret_is_syll = true; Append_Syll(ref ref_syll_seq, ur_stp_syll, flag_new_syll, ur_sylls, ur_word_rec); } ref_cur_state = ur_test_syll; ur_stp_syll.Append(ur_entry); } return(ret_is_syll); }
private Mx.bitbase <enrSYLL> .table_row Split_SyllableList( Mx.bitbase <enrWORD> .table_row ur_words, bool ur_flag_only_errors, System.Collections.Generic.List <SyllTransition> ur_transitions, System.Collections.Generic.List <SyllCode> ur_syll_codes) { Mx.bitbase <enrSYLL_STATE> .populate_bitbase(); var ret_syll = new Mx.bitbase <enrSYLL> .table_row(); foreach (var word_rec in ur_words) { var word_syll = new Mx.bitbase <enrSYLL> .table_row(); var cur_state = enrSYLL_STATE.word_separator; var stp_syll = new System.Text.StringBuilder(); var SYLSEQ = 0; var flag_error = false; foreach (var entry in word_rec[enrWORD.word]) { var entry_lc = entry; if (cur_state == enrSYLL_STATE.word_separator) { entry_lc = entry.ToString().ToLower()[0]; } var found_transition = false; foreach (var transition_rec in ur_transitions) { if (cur_state == transition_rec.cur_state) { found_transition = Append_Syll( entry_lc, transition_rec.match_state, transition_rec.new_syll, ref cur_state, ref SYLSEQ, stp_syll, word_syll, word_rec, ur_syll_codes); if (found_transition) { break; } } } if (found_transition == false) { stp_syll.Append($" - Unknown {cur_state.pname} char: ").Append(entry_lc); flag_error = true; break; } } { var entry_lc = '-'; var found_transition = false; foreach (var transition_rec in ur_transitions) { if (cur_state == transition_rec.cur_state && transition_rec.match_state == enrSYLL_STATE.word_end) { found_transition = Append_Syll( entry_lc, transition_rec.match_state, transition_rec.new_syll, ref cur_state, ref SYLSEQ, stp_syll, word_syll, word_rec, ur_syll_codes); if (found_transition) { break; } } } if (found_transition == false) { stp_syll.Append($" - Unknown {cur_state.pname} char: ").Append(entry_lc); Append_Syll( entry_lc, enrSYLL_STATE.word_end, enrSYLL_DSCR.none, ref cur_state, ref SYLSEQ, stp_syll, word_syll, word_rec, ur_syll_codes); flag_error = true; } } if (flag_error == true || ur_flag_only_errors == false) { foreach (var entry in word_syll) { ret_syll.Add(entry); } } } return(ret_syll); }