Example
Create a new text comparison operation.
const operation = new ComparisonOperation(NutrientViewer.ComparisonOperationType.TEXT, { numberOfContextWords: 2 });
Create a new AI comparison operation.
const aiOperation = new ComparisonOperation(
NutrientViewer.ComparisonOperationType.AI,
{ operationType: NutrientViewer.AIComparisonOperationType.ANALYZE, model: 'gpt4o' }
);
Default Value
{ type: NutrientViewer.ComparisonOperationType.TEXT, options: { numberOfContextWords: 0 } }Hierarchy
Constructors
Parameters
type"text" | "ai"options= {}{
numberOfContextWords?: number;
wordLevel?: boolean;
[key: string]: any;
}
| { … }
Properties
Methods
Returns the AI operation type, if this is an AI comparison
Returns
"analyze" | "tag" | undefined
Returns true if this operation is an AI comparison
Returns
boolean
Returns true if this operation is a text comparison
Returns
boolean
Immutable Record API
31
- "[iterator]"(): IterableIterator<
[
keyof { options?: IComparisonOperationOptions; type: "text"
| "ai" },
"text" | "ai" | IComparisonOperationOptions | undefined,
],
>Returns
IterableIterator<
[
keyof { options?: IComparisonOperationOptions; type: "text"
| "ai" },
"text" | "ai" | IComparisonOperationOptions | undefined
]
>
Returns
thisSee Also
Map#asImmutable
Returns
thisSee Also
Map#asMutable
Returns a new instance of this Record type with all values set to their default values.
Returns
this
- delete<
K extends
keyof { options?: IComparisonOperationOptions; type: "text"
| "ai" },
>(
key: K,
): thisReturns a new instance of this Record type with the value for the specific key set to its default value.
Type Parameters
Kextends keyof { options?: IComparisonOperationOptions; type: "text" | "ai" }Parameters
keyKReturns
this
Parameters
otherunknownReturns
boolean
- get<
K extends
keyof { options?: IComparisonOperationOptions; type: "text"
| "ai" },
>(
key: K,
notSetValue?: unknown,
): { options?: IComparisonOperationOptions; type: "text" | "ai" }[K]Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.
If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.
Parameters
keystringReturns
key is "type" | "options"
Returns
number
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
Parameters
keyPathIterable<unknown>valueunknownReturns
this
Deeply converts this Record to equivalent native JavaScript Object.
Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.
Returns
{ options?: unknown; type: "text" | "ai" }
Shallowly converts this Record to equivalent native JavaScript Object.
Returns
{ options?: IComparisonOperationOptions; type: "text" | "ai" }
Shallowly converts this Record to equivalent JavaScript Object.
Returns
{ options?: IComparisonOperationOptions; type: "text" | "ai" }
Parameters
keyPathIterable<unknown>updater(value: unknown) => unknownReturns
this
Returns
booleanSee Also
Map#wasAltered
Note: Not all methods can be used on a mutable collection or within
withMutations! Onlysetmay be used mutatively.Parameters
mutator(mutable: this) => unknownReturns
thisSee Also
Map#withMutations
ComparisonOperation is a class that provides methods to describe a comparison operation. It encapsulates the type and optional settings for the comparison.
It is an Immutable.Record and thus can be updated using
set(key, value), for example:scale.set("options", { numberOfContextWords: 4 })