Exemple #1
0
/*!
** See if this particular capitalization (dent) is legal with these
** particular affixes.
**
** \param dent
** \param hit
**
** \return
*/
static int entryhasaffixes(struct dent *dent, struct success *hit)
{
    if(hit->prefix && !TSTMASKBIT(dent->mask, hit->prefix->flagbit))
        return 0;
    if(hit->suffix && !TSTMASKBIT(dent->mask, hit->suffix->flagbit))
        return 0;
    return 1; /* Yes, these affixes are legal */
}
Exemple #2
0
/*!
 * Expand a dictionary prefix entry
 *
 * \param croot Char version of rootword
 * \param rootword Root word to expand
 * \param mask Mask bits to expand on
 * \param option Option, see expandmode
 * \param extra Extra info to add to line
 *
 * \return
 */
int ISpellChecker::expand_pre (char *croot, ichar_t *rootword, MASKTYPE mask[], 
				int option, char *extra)
{
    int				entcount;	/* No. of entries to process */
    int				explength;	/* Length of expansions */
    register struct flagent *
				flent;		/* Current table entry */

    for (flent = m_pflaglist, entcount = m_numpflags, explength = 0;
      entcount > 0;
      flent++, entcount--)
	{
		if (TSTMASKBIT (mask, flent->flagbit))
			explength +=
			  pr_pre_expansion (croot, rootword, flent, mask, option, extra);
	}
    return explength;
}
Exemple #3
0
/*!
 * \param word Word to be checked
 * \param ucword Upper-case-only word
 * \param len The length of ucword
 * \param ind Flag index table
 * \param optflags Affix option flags
 * \param pfxent Prefix flag entry if crossonly
 * \param ignoreflagbits Ignore whether affix is legal
 * \pram allhits Keep going after first hit
 */
void ISpellChecker::suf_list_chk (ichar_t *word, ichar_t *ucword, 
						  int len, struct flagptr *ind, int optflags, 
						  struct flagent *pfxent, int ignoreflagbits, int allhits)
{
    register ichar_t *	cp;		/* Pointer into end of ucword */
    int			cond;		/* Condition number */
    struct dent *	dent;		/* Dictionary entry we found */
    int			entcount;	/* Number of entries to process */
    register struct flagent *
			flent;		/* Current table entry */
    int			preadd;		/* Length added to tword2 as prefix */
    register int	tlen;		/* Length of tword */
    ichar_t		tword[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4]; /* Tmp cpy */
    ichar_t		tword2[sizeof tword]; /* 2nd copy for ins_root_cap */

    icharcpy (tword, ucword);
    for (flent = ind->pu.ent, entcount = ind->numents;
      entcount > 0;
      flent++, entcount--)
	{
		if ((optflags & FF_CROSSPRODUCT) != 0
		  &&  (flent->flagflags & FF_CROSSPRODUCT) == 0)
			continue;
		/*
		 * If this is a compound-only affix, ignore it unless we're
		 * looking for that specific thing.
		 */
		if ((flent->flagflags & FF_COMPOUNDONLY) != 0
		  &&  (optflags & FF_COMPOUNDONLY) == 0)
			continue;

		/*
		 * See if the suffix matches.
		 */
		tlen = len - flent->affl;
		if (tlen > 0
		  &&  (flent->affl == 0
			||  icharcmp (flent->affix, ucword + tlen) == 0)
		  &&  tlen + flent->stripl >= flent->numconds)
		{
			/*
			 * The suffix matches.  Remove it, replace it by the "strip"
			 * string (if any), and check the original conditions.
			 */
			icharcpy (tword, ucword);
			cp = tword + tlen;
			if (flent->stripl)
			{
				icharcpy (cp, flent->strip);
				tlen += flent->stripl;
				cp = tword + tlen;
			}
			else
				*cp = '\0';
			for (cond = flent->numconds;  --cond >= 0;  )
			{
				if ((flent->conds[*--cp] & (1 << cond)) == 0)
					break;
			}
			if (cond < 0)
			{
				/*
				 * The conditions match.  See if the word is in the
				 * dictionary.
				 */
				if (ignoreflagbits)
				{
					if ((dent = ispell_lookup (tword, 1)) != NULL)
					{
						cp = tword2;
						if ((optflags & FF_CROSSPRODUCT)
						  &&  pfxent->affl != 0)
						{
							icharcpy (cp, pfxent->affix);
							cp += pfxent->affl;
							*cp++ = '+';
						}
						preadd = cp - tword2;
						icharcpy (cp, tword);
						cp += tlen;
						if ((optflags & FF_CROSSPRODUCT)
						  &&  pfxent->stripl != 0)
						{
							*cp++ = '-';
							icharcpy (cp, pfxent->strip);
							cp += pfxent->stripl;
						}
						if (flent->stripl)
						{
							*cp++ = '-';
							icharcpy (cp, flent->strip);
							cp += flent->stripl;
						}
						if (flent->affl)
						{
							*cp++ = '+';
							icharcpy (cp, flent->affix);
							cp += flent->affl;
						}
					}
				}
				else if ((dent = ispell_lookup (tword, 1)) != NULL
				  &&  TSTMASKBIT (dent->mask, flent->flagbit)
				  &&  ((optflags & FF_CROSSPRODUCT) == 0
					|| TSTMASKBIT (dent->mask, pfxent->flagbit)))
				{
					if (m_numhits < MAX_HITS)
					{
						m_hits[m_numhits].dictent = dent;
						m_hits[m_numhits].prefix = pfxent;
						m_hits[m_numhits].suffix = flent;
						m_numhits++;
					}
					if (!allhits)
					{
#ifndef NO_CAPITALIZATION_SUPPORT
						if (cap_ok (word, &m_hits[0], len))
							return;
						m_numhits = 0;
#else /* NO_CAPITALIZATION_SUPPORT */
						return;
#endif /* NO_CAPITALIZATION_SUPPORT */
					}
				}
			}
		}
	}
}