Пример #1
0
func (this *Locutions) check(s string, acc *set.Set, mw *bool, pref *bool, st *LocutionStatus) bool {
	if this.locut[s] != "" {
		acc.Add(s)
		st.longestMW = acc
		st.overLongest = 0
		LOG.Trace("   Added MW:" + s)
		*mw = true
	} else if this.prefixes.Has(s + "_") {
		acc.Add(s)
		LOG.Trace("   Added PRF:" + s)
		*pref = true
	}

	return *mw || *pref
}
Пример #2
0
func (this *Affixes) lookForCombinedAffixes(suff map[string]*set.Set, pref map[string]*set.Set, w *Word, dic *Dictionary) {
	var i, j, ln int
	var lws, formSuf, formPref, formRoot string
	lws = w.getLCForm()
	ln = len(lws)

	var rulesS *set.Set
	var rulesP *set.Set

	var candidates, cand1 *set.Set

	for i = 1; i <= this.Longest[SUF] && i < ln; i++ {
		if this.ExistingLength[SUF].Has(i) == false {
			TRACE(4, "No suffixes  of size "+strconv.Itoa(i), MOD_AFFIX)
			continue
		}

		for j = 1; j <= this.Longest[PREF] && j <= ln-i; j++ {
			if this.ExistingLength[PREF].Has(j) == false {
				TRACE(4, "No prefixes  of size "+strconv.Itoa(i), MOD_AFFIX)
				continue
			}

			formSuf = lws[ln-i:]
			formPref = lws[0:j]

			rulesS = suff[formSuf]
			if rulesS.Size() == 0 || rulesS.List()[0].(string) != formSuf {
				TRACE(3, "No rules for suffix "+formSuf+" (size "+strconv.Itoa(i), MOD_AFFIX)
				continue
			}

			rulesP = suff[formPref]
			if rulesP.Size() == 0 || rulesP.List()[0].(string) != formPref {
				TRACE(3, "No rules for prefix "+formPref+" (size "+strconv.Itoa(i), MOD_AFFIX)
				continue
			}

			formRoot = lws[0 : ln-i][j:]
			TRACE(3, "Trying a decomposition: "+formPref+"+"+formRoot+"+"+formSuf, MOD_AFFIX)

			TRACE(3, "Found "+strconv.Itoa(rulesS.Size())+" rules for suffix "+formSuf+" (size "+strconv.Itoa(i), MOD_AFFIX)
			TRACE(3, "Found "+strconv.Itoa(rulesP.Size())+" rules for prefix "+formPref+" (size "+strconv.Itoa(i), MOD_AFFIX)

			//wfid := w.foundInDict()

			lrulesS := rulesS.List()
			lrulesP := rulesP.List()

			for s := 0; s < rulesS.Size(); s++ {
				sufit := lrulesS[s].(*sufrule)
				for p := 0; p < rulesP.Size(); p++ {
					prefit := lrulesP[p].(*sufrule)
					candidates = set.New()
					cand1 = this.GenerateRoots(SUF, sufit, formRoot)
					this.accen.FixAccentutation(cand1, sufit)
					lcand1 := cand1.List()
					for _, c := range lcand1 {
						cand2 := this.GenerateRoots(PREF, prefit, c.(string))
						this.accen.FixAccentutation(cand2, prefit)
						candidates.Add(cand2)
					}
				}
			}
		}
	}
}