ConceptPortal-public/rsconcept/frontend/src/models/rsform.ts

193 lines
4.0 KiB
TypeScript
Raw Normal View History

/**
* Module: Models for formal representation for systems of concepts.
*/
import { Graph } from '@/utils/Graph'
2023-11-30 02:14:24 +03:00
import { ILibraryItemEx, ILibraryUpdateData } from './library'
import { IArgumentInfo, ParsingStatus, ValueClass } from './rslang'
2023-07-29 03:31:21 +03:00
/**
* Represents Constituenta type.
*/
export enum CstType {
BASE = 'basic',
STRUCTURED = 'structure',
TERM = 'term',
AXIOM = 'axiom',
FUNCTION = 'function',
PREDICATE = 'predicate',
CONSTANT = 'constant',
THEOREM = 'theorem'
}
2023-12-26 14:23:51 +03:00
// CstType constant for category dividers in TemplateSchemas. TODO: create separate structure for templates
2023-11-04 01:29:21 +03:00
export const CATEGORY_CST_TYPE = CstType.THEOREM;
/**
* Represents Constituenta classification in terms of system of concepts.
*/
2023-08-16 00:39:16 +03:00
export enum CstClass {
BASIC = 'basic',
DERIVED = 'derived',
STATEMENT = 'statement',
TEMPLATE = 'template'
}
/**
* Represents formal expression Status.
*/
2023-09-11 20:31:54 +03:00
export enum ExpressionStatus {
2023-09-26 00:24:50 +03:00
VERIFIED = 'verified',
2023-09-11 20:31:54 +03:00
INCORRECT = 'incorrect',
2023-09-26 00:24:50 +03:00
INCALCULABLE = 'incalculable',
2023-10-02 23:43:29 +03:00
PROPERTY = 'property',
2023-09-26 00:24:50 +03:00
UNDEFINED = 'undefined',
UNKNOWN = 'unknown',
2023-09-11 20:31:54 +03:00
}
/**
2023-12-26 14:23:51 +03:00
* Represents word form for natural language.
*/
export interface TermForm {
text: string
tags: string
2023-07-20 17:11:03 +03:00
}
/**
* Represents Constituenta basic persistent data.
*/
export interface IConstituentaMeta {
id: number
schema: number
order: number
alias: string
convention: string
cst_type: CstType
definition_formal: string
definition_raw: string
definition_resolved: string
term_raw: string
term_resolved: string
term_forms: TermForm[]
}
/**
* Represents Constituenta.
*/
export interface IConstituenta
extends IConstituentaMeta {
cst_class: CstClass
status: ExpressionStatus
is_template: boolean
parse: {
status: ParsingStatus
valueClass: ValueClass
typification: string
syntaxTree: string
2023-11-06 02:20:16 +03:00
args: IArgumentInfo[]
}
}
/**
* Represents Constituenta list.
*/
export interface IConstituentaList {
items: number[]
}
/**
* Represents constituenta data, used in creation process.
*/
export interface ICstCreateData
extends Pick<
IConstituentaMeta,
'alias' | 'cst_type' | 'definition_raw' | 'term_raw' |
'convention' | 'definition_formal' | 'term_forms'
> {
insert_after: number | null
}
/**
* Represents data, used in ordering constituents in a list.
*/
export interface ICstMovetoData extends IConstituentaList {
move_to: number
}
/**
* Represents data, used in updating persistent attributes in {@link IConstituenta}.
*/
export interface ICstUpdateData
2023-09-25 14:17:52 +03:00
extends Pick<IConstituentaMeta, 'id'>,
Partial<Pick<IConstituentaMeta, | 'alias' | 'convention' | 'definition_formal' | 'definition_raw' | 'term_raw' | 'term_forms'>> {}
/**
* Represents data, used in renaming {@link IConstituenta}.
*/
export interface ICstRenameData
extends Pick<IConstituentaMeta, 'id' | 'alias' | 'cst_type' > {}
/**
* Represents data response when creating {@link IConstituenta}.
*/
export interface ICstCreatedResponse {
new_cst: IConstituentaMeta
schema: IRSFormData
}
/**
* Represents {@link IRSForm} statistics.
*/
2023-07-20 17:11:03 +03:00
export interface IRSFormStats {
2023-07-25 20:27:29 +03:00
count_all: number
count_errors: number
count_property: number
2023-12-26 14:23:51 +03:00
count_incalculable: number
2023-07-25 20:27:29 +03:00
2023-12-26 14:23:51 +03:00
count_text_term: number
2023-08-27 15:39:49 +03:00
count_definition: number
count_convention: number
2023-07-25 20:27:29 +03:00
count_base: number
count_constant: number
count_structured: number
count_axiom: number
count_term: number
count_function: number
count_predicate: number
count_theorem: number
2023-07-20 17:11:03 +03:00
}
/**
* Represents formal explication for set of concepts.
*/
2023-08-25 22:51:20 +03:00
export interface IRSForm
2023-11-30 02:14:24 +03:00
extends ILibraryItemEx {
items: IConstituenta[]
stats: IRSFormStats
2023-07-29 21:23:18 +03:00
graph: Graph
2023-07-20 17:11:03 +03:00
}
/**
* Represents data for {@link IRSForm} provided by backend.
*/
2023-07-30 00:47:07 +03:00
export interface IRSFormData extends Omit<IRSForm, 'stats' | 'graph'> {}
/**
* Represents data, used for creating {@link IRSForm}.
*/
export interface IRSFormCreateData
2023-08-25 22:51:20 +03:00
extends ILibraryUpdateData {
2023-07-25 20:27:29 +03:00
file?: File
fileName?: string
2023-07-20 17:11:03 +03:00
}
/**
* Represents data, used for uploading {@link IRSForm} as file.
*/
2023-07-27 22:04:25 +03:00
export interface IRSFormUploadData {
load_metadata: boolean
file: File
fileName: string
}