本文整理汇总了C++中Melder_dup函数的典型用法代码示例。如果您正苦于以下问题:C++ Melder_dup函数的具体用法?C++ Melder_dup怎么用?C++ Melder_dup使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Melder_dup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PairDistribution_to_Stringses
void PairDistribution_to_Stringses (PairDistribution me, long nout, autoStrings *strings1_out, autoStrings *strings2_out) {
try {
long nin = my pairs -> size, iin;
if (nin < 1)
Melder_throw (U"No candidates.");
if (nout < 1)
Melder_throw (U"Number of generated string pairs should be positive.");
double total = PairDistributions_getTotalWeight_checkPositive (me);
autoStrings strings1 = Thing_new (Strings);
strings1 -> numberOfStrings = nout;
strings1 -> strings = NUMvector <char32 *> (1, nout);
autoStrings strings2 = Thing_new (Strings);
strings2 -> numberOfStrings = nout;
strings2 -> strings = NUMvector <char32 *> (1, nout);
for (long iout = 1; iout <= nout; iout ++) {
do {
double rand = NUMrandomUniform (0, total), sum = 0.0;
for (iin = 1; iin <= nin; iin ++) {
PairProbability prob = static_cast <PairProbability> (my pairs -> item [iin]);
sum += prob -> weight;
if (rand <= sum) break;
}
} while (iin > nin); /* Guard against rounding errors. */
PairProbability prob = static_cast <PairProbability> (my pairs -> item [iin]);
if (! prob -> string1 || ! prob -> string2)
Melder_throw (U"No string in probability pair ", iin, U".");
strings1 -> strings [iout] = Melder_dup (prob -> string1);
strings2 -> strings [iout] = Melder_dup (prob -> string2);
}
*strings1_out = strings1.move();
*strings2_out = strings2.move();
} catch (MelderError) {
Melder_throw (me, U": generation of Stringses not performed.");
}
}
示例2: FileInMemory_create
autoFileInMemory FileInMemory_create (MelderFile file) {
try {
if (! MelderFile_readable (file)) {
Melder_throw (U"File not readable.");
}
long length = MelderFile_length (file);
if (length <= 0) {
Melder_throw (U"File is empty.");
}
autoFileInMemory me = Thing_new (FileInMemory);
my d_path = Melder_dup (file -> path);
my d_id = Melder_dup (MelderFile_name (file));
my d_numberOfBytes = length;
my ownData = true;
my d_data = NUMvector <char> (0, my d_numberOfBytes); // includes room for a final null byte in case the file happens to contain text
MelderFile_open (file);
for (long i = 0; i < my d_numberOfBytes; i++) {
unsigned int number = bingetu1 (file -> filePointer);
my d_data[i] = number;
}
my d_data[my d_numberOfBytes] = 0; // one extra
MelderFile_close (file);
return me;
} catch (MelderError) {
Melder_throw (U"FileInMemory not created from \"", Melder_fileToPath (file), U"\".");
}
}
示例3: PairProbability_create
autoPairProbability PairProbability_create (const char32 *string1, const char32 *string2, double weight) {
autoPairProbability me = Thing_new (PairProbability);
my string1 = Melder_dup (string1);
my string2 = Melder_dup (string2);
my weight = weight;
return me;
}
示例4: ResultsMFC_removeUnsharedStimuli
autoResultsMFC ResultsMFC_removeUnsharedStimuli (ResultsMFC me, ResultsMFC thee) {
try {
autoResultsMFC him = ResultsMFC_create (thy numberOfTrials);
his numberOfTrials = 0;
for (long i = 1; i <= thy numberOfTrials; i ++) {
bool present = false;
for (long j = 1; j <= my numberOfTrials; j ++) {
if (str32equ (thy result [i]. stimulus, my result [j]. stimulus)) {
present = true;
break;
}
}
if (present) {
his numberOfTrials ++;
his result [his numberOfTrials]. stimulus = Melder_dup (thy result [i]. stimulus);
his result [his numberOfTrials]. response = Melder_dup (thy result [i]. response);
}
}
if (his numberOfTrials == 0)
Melder_throw (U"No shared stimuli.");
return him;
} catch (MelderError) {
Melder_throw (me, U" & ", thee, U": unshared stimuli not removed.");
}
}
示例5: v_copy
void structFileInMemory :: v_copy (thou) {
thouart (FileInMemory);
FileInMemory_Parent :: v_copy (thee);
thy d_path = Melder_dup (d_path);
thy d_id = Melder_dup (d_id);
thy d_numberOfBytes = d_numberOfBytes;
thy d_data = NUMvector<char> (0, d_numberOfBytes);
memcpy (thy d_data, d_data, d_numberOfBytes+1);
}
示例6: v_copy
void structFileInMemory :: v_copy (Daata thee_Daata) {
FileInMemory thee = static_cast <FileInMemory> (thee_Daata);
our FileInMemory_Parent :: v_copy (thee);
thy d_path = Melder_dup (our d_path);
thy d_id = Melder_dup (our d_id);
thy d_numberOfBytes = our d_numberOfBytes;
thy ownData = our ownData;
thy d_data = NUMvector<char> (0, our d_numberOfBytes);
memcpy (thy d_data, our d_data, our d_numberOfBytes + 1);
}
示例7: LogisticRegression_create
autoLogisticRegression LogisticRegression_create (const char32 *dependent1, const char32 *dependent2) {
try {
autoLogisticRegression me = Thing_new (LogisticRegression);
Regression_init (me.peek());
my dependent1 = Melder_dup (dependent1);
my dependent2 = Melder_dup (dependent2);
return me;
} catch (MelderError) {
Melder_throw (U"LogisticRegression not created.");
}
}
示例8: OTMultiEditor_create
OTMultiEditor OTMultiEditor_create (const char32 *title, OTMulti grammar) {
try {
autoOTMultiEditor me = Thing_new (OTMultiEditor);
my data = grammar;
my form1 = Melder_dup (U"");
my form2 = Melder_dup (U"");
HyperPage_init (me.peek(), title, grammar);
return me.transfer();
} catch (MelderError) {
Melder_throw (U"OTMulti window not created.");
}
}
示例9: FileInMemory_createWithData
FileInMemory FileInMemory_createWithData (long numberOfBytes, const char *data, const char32 *path, const char32 *id) {
try {
autoFileInMemory me = Thing_new (FileInMemory);
my d_path = Melder_dup (path);
my d_id = Melder_dup (id);
my d_numberOfBytes = numberOfBytes;
my d_data = const_cast<char *> (data); // copy pointer to data only
return me.transfer ();
} catch (MelderError) {
Melder_throw (U"FileInMemory not create from data.");
}
}
示例10: SpeechSynthesizer_create
autoSpeechSynthesizer SpeechSynthesizer_create (const char32 *voiceLanguageName, const char32 *voiceVariantName) {
try {
autoSpeechSynthesizer me = Thing_new (SpeechSynthesizer);
(void) SpeechSynthesizer_getVoiceLanguageCodeFromName (me.get(), voiceLanguageName);
(void) SpeechSynthesizer_getVoiceVariantCodeFromName (me.get(), voiceVariantName);
my d_voiceLanguageName = Melder_dup (voiceLanguageName);
my d_voiceVariantName = Melder_dup (voiceVariantName);
SpeechSynthesizer_setTextInputSettings (me.get(), SpeechSynthesizer_INPUT_TEXTONLY, SpeechSynthesizer_PHONEMECODINGS_KIRSHENBAUM);
SpeechSynthesizer_setSpeechOutputSettings (me.get(), 44100, 0.01, 50, 50, 175, true, SpeechSynthesizer_PHONEMECODINGS_IPA);
SpeechSynthesizer_initEspeak ();
return me;
} catch (MelderError) {
Melder_throw (U"SpeechSynthesizer not created.");
}
}
示例11: EditDistanceTable_to_TableOfReal
TableOfReal EditDistanceTable_to_TableOfReal (EditDistanceTable me) {
try {
autoTableOfReal thee = TableOfReal_create (my numberOfRows, my numberOfColumns);
for (long j = 1; j <= my numberOfColumns; j++) {
thy columnLabels[j] = Melder_dup (my columnLabels[j]);
}
for (long i = 1; i <= my numberOfRows; i++) {
thy rowLabels[i] = Melder_dup (my rowLabels[i]);
}
NUMmatrix_copyElements<double> (my data, thy data, 1, my numberOfRows, 1, my numberOfColumns);
return thee.transfer();
} catch (MelderError) {
Melder_throw (me, U": no TableOfReal created.");
}
}
示例12: ERPTier_extractEventsWhereColumn_string
autoERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table,
long columnNumber, int which_Melder_STRING, const char32 *criterion)
{
try {
Table_checkSpecifiedColumnNumberWithinRange (table, columnNumber);
if (my events -> size != table -> rows -> size)
Melder_throw (me, U" & ", table, U": the number of rows in the table (", table -> rows -> size,
U") doesn't match the number of events (", my events -> size, U").");
autoERPTier thee = Thing_new (ERPTier);
Function_init (thee.peek(), my xmin, my xmax);
thy numberOfChannels = my numberOfChannels;
thy channelNames = NUMvector <char32 *> (1, thy numberOfChannels);
for (long ichan = 1; ichan <= thy numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy events = SortedSetOfDouble_create ();
for (long ievent = 1; ievent <= my events -> size; ievent ++) {
ERPPoint oldEvent = my event (ievent);
TableRow row = table -> row (ievent);
if (Melder_stringMatchesCriterion (row -> cells [columnNumber]. string, which_Melder_STRING, criterion)) {
autoERPPoint newEvent = Data_copy (oldEvent);
Collection_addItem_move (thy events.get(), newEvent.move());
}
}
if (thy events -> size == 0) {
Melder_warning (U"No event matches criterion.");
}
return thee;
} catch (MelderError) {
Melder_throw (me, U": events not extracted.");
}
}
示例13: Strings_append
autoStrings Strings_append (Collection me) {
try {
long index = 1, numberOfStrings = 0;
for (long i = 1; i <= my size; i++) {
Strings s = (Strings) my item[i];
numberOfStrings += s -> numberOfStrings;
}
autoStrings thee = Strings_createFixedLength (numberOfStrings);
for (long i = 1; i <= my size; i++) {
Strings s = (Strings) my item[i];
for (long j = 1; j <= s -> numberOfStrings; j++, index++) {
if (s -> strings[j] == 0) {
continue;
}
thy strings [index] = Melder_dup (s -> strings[j]);
}
}
return thee;
} catch (MelderError) {
Melder_throw (me, U": not appended.");
}
}
示例14: Strings_to_Distributions
Distributions Strings_to_Distributions (Strings me) {
try {
autoDistributions thee = Distributions_create (my numberOfStrings, 1);
long idist = 0;
for (long i = 1; i <= my numberOfStrings; i ++) {
char32 *string = my strings [i];
long where = 0;
long j = 1;
for (; j <= idist; j ++)
if (str32equ (thy rowLabels [j], string))
{ where = j; break; }
if (where) {
thy data [j] [1] += 1.0;
} else {
thy rowLabels [++ idist] = Melder_dup (string);
thy data [idist] [1] = 1.0;
}
}
thy numberOfRows = idist;
TableOfReal_sortByLabel (thee.peek(), 1, 0);
return thee.transfer();
} catch (MelderError) {
Melder_throw (me, U": distribution not computed.");
}
}
示例15: Strings_readFromRawTextFile
autoStrings Strings_readFromRawTextFile (MelderFile file) {
try {
autoMelderReadText text = MelderReadText_createFromFile (file);
/*
* Count number of strings.
*/
int64 n = MelderReadText_getNumberOfLines (text.peek());
/*
* Create.
*/
autoStrings me = Thing_new (Strings);
if (n > 0) my strings = NUMvector <char32 *> (1, n);
my numberOfStrings = n;
/*
* Read strings.
*/
for (long i = 1; i <= n; i ++) {
char32 *line = MelderReadText_readLine (text.peek());
my strings [i] = Melder_dup (line);
}
return me;
} catch (MelderError) {
Melder_throw (U"Strings not read from raw text file ", file, U".");
}
}