mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Embed arguments in typification
update pyconcept to 1.3.0
This commit is contained in:
parent
254499daa4
commit
6e81c13be5
|
@ -3,9 +3,9 @@
|
|||
|
||||
# Application settings
|
||||
SECRET_KEY=django-insecure-)rq@!&v7l2r%2%q#n!uq+zk@=&yc0^&ql^7%2!%9u)vt1x&j=d
|
||||
ALLOWED_HOSTS=rs.acconcept.ru;localhost
|
||||
CSRF_TRUSTED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000
|
||||
CORS_ALLOWED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000
|
||||
ALLOWED_HOSTS=rs.acconcept.ru;localhost;portal.acconcept.ru
|
||||
CSRF_TRUSTED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
|
||||
CORS_ALLOWED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
|
||||
|
||||
|
||||
# File locations
|
||||
|
|
|
@ -34,6 +34,7 @@ class TestIntegrations(TestCase):
|
|||
schema = self._default_schema()
|
||||
out1 = json.loads(pc.check_expression(schema, 'X1=X1'))
|
||||
self.assertTrue(out1['parseResult'])
|
||||
self.assertEqual(len(out1['args']), 0)
|
||||
|
||||
out2 = json.loads(pc.check_expression(schema, 'X1=X2'))
|
||||
self.assertFalse(out2['parseResult'])
|
||||
|
|
|
@ -9,7 +9,7 @@ import TextArea from '../../components/Common/TextArea';
|
|||
import { DumpBinIcon, HelpIcon, SaveIcon, SmallPlusIcon } from '../../components/Icons';
|
||||
import { useRSForm } from '../../context/RSFormContext';
|
||||
import { type CstType, EditMode, ICstUpdateData, SyntaxTree } from '../../utils/models';
|
||||
import { getCstTypeLabel, mapStatusInfo } from '../../utils/staticUI';
|
||||
import { getCstTypeLabel, getCstTypificationLabel, mapStatusInfo } from '../../utils/staticUI';
|
||||
import EditorRSExpression from './EditorRSExpression';
|
||||
import ViewSideConstituents from './elements/ViewSideConstituents';
|
||||
|
||||
|
@ -64,7 +64,7 @@ function EditorConstituenta({ activeID, onShowAST, onCreateCst, onOpenEdit, onDe
|
|||
setTerm(activeCst.term?.raw ?? '');
|
||||
setTextDefinition(activeCst.definition?.text?.raw ?? '');
|
||||
setExpression(activeCst.definition?.formal ?? '');
|
||||
setTypification(activeCst?.parse?.typification || 'N/A');
|
||||
setTypification(activeCst ? getCstTypificationLabel(activeCst) : 'N/A');
|
||||
} else if (schema && schema?.items.length > 0) {
|
||||
onOpenEdit(schema.items[0].id);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { useRSForm } from '../../context/RSFormContext';
|
|||
import { useConceptTheme } from '../../context/ThemeContext';
|
||||
import { prefixes } from '../../utils/constants';
|
||||
import { CstType, IConstituenta, ICstMovetoData } from '../../utils/models'
|
||||
import { getCstTypePrefix, getCstTypeShortcut, getTypeLabel, mapStatusInfo } from '../../utils/staticUI';
|
||||
import { getCstTypePrefix, getCstTypeShortcut, getCstTypificationLabel, mapStatusInfo } from '../../utils/staticUI';
|
||||
|
||||
interface EditorItemsProps {
|
||||
onOpenEdit: (cstID: number) => void
|
||||
|
@ -192,7 +192,7 @@ function EditorItems({ onOpenEdit, onCreateCst, onDeleteCst }: EditorItemsProps)
|
|||
{
|
||||
name: 'Тип',
|
||||
id: 'type',
|
||||
cell: (cst: IConstituenta) => <div style={{ fontSize: 12 }}>{getTypeLabel(cst)}</div>,
|
||||
cell: (cst: IConstituenta) => <div style={{ fontSize: 12 }}>{getCstTypificationLabel(cst)}</div>,
|
||||
width: '140px',
|
||||
minWidth: '100px',
|
||||
maxWidth: '140px',
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useRSForm } from '../../context/RSFormContext';
|
|||
import useCheckExpression from '../../hooks/useCheckExpression';
|
||||
import { TokenID } from '../../utils/enums';
|
||||
import { IConstituenta, IRSErrorDescription, SyntaxTree } from '../../utils/models';
|
||||
import { getCstExpressionPrefix } from '../../utils/staticUI';
|
||||
import { getCstExpressionPrefix, getTypificationLabel } from '../../utils/staticUI';
|
||||
import ParsingResult from './elements/ParsingResult';
|
||||
import RSLocalButton from './elements/RSLocalButton';
|
||||
import RSTokenButton from './elements/RSTokenButton';
|
||||
|
@ -67,7 +67,11 @@ function EditorRSExpression({
|
|||
}
|
||||
expressionCtrl.current!.focus();
|
||||
setIsModified(false);
|
||||
setTypification(parse.typification);
|
||||
setTypification(getTypificationLabel({
|
||||
isValid: parse.parseResult,
|
||||
resultType: parse.typification,
|
||||
args: parse.args
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ConceptTooltip from '../../../components/Common/ConceptTooltip';
|
||||
import { IConstituenta } from '../../../utils/models';
|
||||
import { getTypeLabel } from '../../../utils/staticUI';
|
||||
import { getCstTypificationLabel } from '../../../utils/staticUI';
|
||||
|
||||
interface ConstituentaTooltipProps {
|
||||
data: IConstituenta
|
||||
|
@ -14,7 +14,7 @@ function ConstituentaTooltip({ data, anchor }: ConstituentaTooltipProps) {
|
|||
className='max-w-[25rem] min-w-[25rem]'
|
||||
>
|
||||
<h1>Конституента {data.alias}</h1>
|
||||
<p><b>Типизация: </b>{getTypeLabel(data)}</p>
|
||||
<p><b>Типизация: </b>{getCstTypificationLabel(data)}</p>
|
||||
<p><b>Термин: </b>{data.term.resolved || data.term.raw}</p>
|
||||
{data.definition.formal && <p><b>Выражение: </b>{data.definition.formal}</p>}
|
||||
{data.definition.text.resolved && <p><b>Определение: </b>{data.definition.text.resolved}</p>}
|
||||
|
|
|
@ -64,6 +64,11 @@ export interface ISyntaxTreeNode {
|
|||
}
|
||||
export type SyntaxTree = ISyntaxTreeNode[]
|
||||
|
||||
export interface IFunctionArg {
|
||||
alias: string
|
||||
typification: string
|
||||
}
|
||||
|
||||
export interface IExpressionParse {
|
||||
parseResult: boolean
|
||||
syntax: Syntax
|
||||
|
@ -72,6 +77,7 @@ export interface IExpressionParse {
|
|||
errors: IRSErrorDescription[]
|
||||
astText: string
|
||||
ast: SyntaxTree
|
||||
args: IFunctionArg[]
|
||||
}
|
||||
|
||||
export interface IRSExpression {
|
||||
|
@ -113,6 +119,7 @@ export interface IConstituenta {
|
|||
valueClass: ValueClass
|
||||
typification: string
|
||||
syntaxTree: string
|
||||
args: IFunctionArg[]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { LayoutTypes } from 'reagraph';
|
||||
|
||||
import { resolveErrorClass,RSErrorClass, RSErrorType, TokenID } from './enums';
|
||||
import { CstMatchMode,CstType, DependencyMode,ExpressionStatus, type IConstituenta, IRSErrorDescription,type IRSForm, ISyntaxTreeNode,ParsingStatus, ValueClass } from './models';
|
||||
import { CstMatchMode, CstType, DependencyMode,ExpressionStatus, IConstituenta,
|
||||
IFunctionArg,IRSErrorDescription, IRSForm,
|
||||
ISyntaxTreeNode, ParsingStatus, ValueClass
|
||||
} from './models';
|
||||
|
||||
export interface IRSButtonData {
|
||||
text: string
|
||||
|
@ -14,16 +17,6 @@ export interface IStatusInfo {
|
|||
tooltip: string
|
||||
}
|
||||
|
||||
export function getTypeLabel(cst: IConstituenta): string {
|
||||
if (cst.parse?.typification) {
|
||||
return cst.parse.typification;
|
||||
}
|
||||
if (cst.parse?.status !== ParsingStatus.VERIFIED) {
|
||||
return 'N/A';
|
||||
}
|
||||
return 'Логический';
|
||||
}
|
||||
|
||||
export function getCstDescription(cst: IConstituenta): string {
|
||||
if (cst.cstType === CstType.STRUCTURED) {
|
||||
return (
|
||||
|
@ -381,7 +374,8 @@ export function getMockConstituenta(id: number, alias: string, type: CstType, co
|
|||
status: ParsingStatus.INCORRECT,
|
||||
valueClass: ValueClass.INVALID,
|
||||
typification: 'N/A',
|
||||
syntaxTree: ''
|
||||
syntaxTree: '',
|
||||
args: []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -394,6 +388,32 @@ export function getCloneTitle(schema: IRSForm): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function getTypificationLabel({isValid, resultType, args}: {
|
||||
isValid: boolean,
|
||||
resultType: string,
|
||||
args: IFunctionArg[]
|
||||
}): string {
|
||||
if (!isValid) {
|
||||
return 'N/A';
|
||||
}
|
||||
if (resultType === '') {
|
||||
resultType = 'Логический'
|
||||
}
|
||||
if (args.length === 0) {
|
||||
return resultType;
|
||||
}
|
||||
const argsText = args.map(arg => arg.typification).join(', ');
|
||||
return `${resultType} 🠔 [${argsText}]`;
|
||||
}
|
||||
|
||||
export function getCstTypificationLabel(cst: IConstituenta): string {
|
||||
return getTypificationLabel({
|
||||
isValid: cst.parse.status === ParsingStatus.VERIFIED,
|
||||
resultType: cst.parse.typification,
|
||||
args: cst.parse.args
|
||||
});
|
||||
}
|
||||
|
||||
export function getRSErrorPrefix(error: IRSErrorDescription): string {
|
||||
const id = error.errorType.toString(16)
|
||||
switch(resolveErrorClass(error.errorType)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user