コード例 #1
0
void EditCostsTable_setSubstitutionCosts (EditCostsTable me, wchar_t *targets, wchar_t *sources, double cost) {
	try {
		autoNUMvector<long> targetIndex (1, my numberOfRows);
		autoNUMvector<long> sourceIndex (1, my numberOfRows);
		long ntargets = 0;
		for (wchar_t *token = Melder_firstToken (targets); token != 0; token = Melder_nextToken ()) {
			long index = EditCostsTable_getTargetIndex (me, token);
			if (index > 0) {
				targetIndex[++ntargets] = index;
			}
		}
		if (ntargets == 0 && targets != 0 && targets[1] != '\0') {
			ntargets = 1; targetIndex[1] = my numberOfRows - 1;
		}
		long nsources = 0;
		for (wchar_t *token = Melder_firstToken (sources); token != 0; token = Melder_nextToken ()) {
			long index = EditCostsTable_getSourceIndex (me, token);
			if (index > 0) {
				sourceIndex[++nsources] = index;
			}
		}
		if (nsources == 0 && sources != 0 && sources[1] != '\0') {
			nsources = 1; sourceIndex[1] = my numberOfColumns - 1;
		}
		for (long i = 1; i <= ntargets; i++) {
			long irow = targetIndex[i];
			for (long j = 1; j <= nsources; j++) {
				my data [irow][sourceIndex[j]] = cost;
			}
		}
	} catch (MelderError) {
		Melder_throw (me, ": substitution costs not set.");
	}
}
コード例 #2
0
ファイル: EditDistanceTable.cpp プロジェクト: psibre/praat
void EditCostsTable_setSubstitutionCosts (EditCostsTable me, char32 *targets, char32 *sources, double cost) {
    try {
        autoNUMvector<long> targetIndex (1, my numberOfRows);
        autoNUMvector<long> sourceIndex (1, my numberOfRows);
        long numberOfTargetSymbols = 0;
        for (char32 *token = Melder_firstToken (targets); token != 0; token = Melder_nextToken ()) {
            long index = EditCostsTable_getTargetIndex (me, token);
            if (index > 0) {
                targetIndex[++numberOfTargetSymbols] = index;
            }
        }
        if (numberOfTargetSymbols == 0) {
            targetIndex[++numberOfTargetSymbols] = my numberOfRows - 1;
        }
        long numberOfSourceSymbols = 0;
        for (char32 *token = Melder_firstToken (sources); token != 0; token = Melder_nextToken ()) {
            long index = EditCostsTable_getSourceIndex (me, token);
            if (index > 0) {
                sourceIndex[++numberOfSourceSymbols] = index;
            }
        }
        if (numberOfSourceSymbols == 0) {
            sourceIndex[++numberOfSourceSymbols] = my numberOfColumns - 1;
        }
        for (long i = 1; i <= numberOfTargetSymbols; i++) {
            long irow = targetIndex[i];
            for (long j = 1; j <= numberOfSourceSymbols; j++) {
                my data [irow][sourceIndex[j]] = cost;
            }
        }
    } catch (MelderError) {
        Melder_throw (me, U": substitution costs not set.");
    }
}
コード例 #3
0
ファイル: vwebutils.cpp プロジェクト: getwindow/vnote
bool VWebUtils::alterHtmlAsTarget(const QUrl &p_baseUrl, QString &p_html, const QString &p_target) const
{
    int idx = targetIndex(p_target);
    if (idx == -1) {
        return false;
    }

    bool altered = false;
    for (auto const & act : m_copyTargets[idx].m_actions) {
        if (const_cast<VWebUtils *>(this)->alterHtmlByTargetAction(p_baseUrl, p_html, act)) {
            altered = true;
        }
    }

    return altered;
}