Skip to content

Commit

Permalink
Parse and denote more determiners
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Sep 26, 2023
1 parent afc0b74 commit f7e06cc
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ interface Quantification {
}

const quantifiers: Record<string, CovertValue> = {
: '[∃]',
: '[∀]',
: '∃',
sía: '¬∃',
tútu: '∀',
: '∀.SING',
túq: '∀.CUML',
báq: 'GEN',
: 'EXO',
: 'ENDO',
: 'DEM',
níjuı: 'PROX',
};

/**
Expand Down
56 changes: 55 additions & 1 deletion src/semantics/denote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ test('it denotes the optative speech act', () => {

test('it denotes the promissive speech act', () => {
expect(d('Jıa faq sía huı nha')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nue.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t' ∧ faq.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t ∧ huı.𝘸(a)(𝘦')))(𝘦) | t' > t0\"",
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nue.w(λ𝘸. ¬∃𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ huı.𝘸(𝘢)(𝘦'). ∃𝘦'. τ(𝘦') ⊆ t ∧ faq.𝘸(𝘢)(𝘦'))(𝘦) | t > t0\"",
);
});

Expand Down Expand Up @@ -248,10 +248,64 @@ test('it denotes sá', () => {

test('it denotes tú', () => {
expect(d('Maı jí tú poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. ∀.SING 𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(𝘢)(𝘦'). (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(𝘢)(𝘦') | animate(𝘢)))(𝘦)\"",
);
});

test('it denotes sía', () => {
expect(d('Maı jí sía poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. ¬∃𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(𝘢)(𝘦'). (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(𝘢)(𝘦') | animate(𝘢)))(𝘦)\"",
);
});

test('it denotes túq', () => {
expect(d('Maı jí túq poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. ∀.CUML 𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(𝘢)(𝘦'). (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(𝘢)(𝘦') | animate(𝘢)))(𝘦)\"",
);
});

test('it denotes tútu', () => {
expect(d('Maı jí tútu poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. ∀𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(𝘢)(𝘦'). (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(𝘢)(𝘦') | animate(𝘢)))(𝘦)\"",
);
});

test('it denotes báq', () => {
expect(d('Maı jí báq poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. GEN 𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(𝘢)(𝘦'). (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(𝘢)(𝘦') | animate(𝘢)))(𝘦)\"",
);
});

test('it denotes ní', () => {
expect(d('Maı jí ní poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(a)(𝘦')))(𝘦) | animate(a) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nıka.w(a)(𝘦)\"",
);
});

test('it denotes níjuı', () => {
expect(d('Maı jí níjuı poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(a)(𝘦')))(𝘦) | animate(a) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nıka.w(a)(𝘦) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ tıjuı.w(a, jí)(𝘦)\"",
);
});

test('it denotes níjao', () => {
expect(d('Maı jí níjao poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t' ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t ∧ poq.𝘸(a)(𝘦')))(𝘦) | animate(a)\"",
);
});

test('it denotes ké', () => {
expect(d('Maı jí ké poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(a)(𝘦')))(𝘦) | animate(a) | ¬∃𝘦. τ(𝘦) <.near t0 ∧ meakuq.w(a)(𝘦)\"",
);
});

test('it denotes hú', () => {
expect(d('Maı jí hú poq')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. (∃𝘦'. τ(𝘦') ⊆ t ∧ AGENT(𝘦')(𝘸) = jí ∧ maı.𝘸(a)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t' ∧ poq.𝘸(a)(𝘦')))(𝘦) | animate(a) | ∃𝘦. τ(𝘦) <.near t0 ∧ meakuq.w(a)(𝘦)\"",
);
});

test('it denotes imperfective aspect + quantification', () => {
expect(d('Chụmjoaı jí sá deo')).toMatchInlineSnapshot(
"\"∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ ruaq.w(λ𝘸. ∃𝘢 : ∃𝘦'. τ(𝘦') ⊆ t' ∧ deo.𝘸(𝘢)(𝘦'). (∀𝘸' : IW(𝘸')(𝘸)(t). (∃𝘦'. t ⊆ τ(𝘦') ∧ AGENT(𝘦')(𝘸') = jí ∧ joaı.𝘸'(𝘢)(𝘦') | ∃𝘦'. τ(𝘦') ⊆ t' ∧ deo.𝘸'(𝘢)(𝘦')) | animate(𝘢)))(𝘦)\"",
Expand Down
184 changes: 182 additions & 2 deletions src/semantics/denote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import {
abstract,
typesEqual,
AnimacyClass,
not,
everySing,
everyCuml,
gen,
} from './model';
import {
filterPresuppositions,
Expand All @@ -53,6 +57,7 @@ import {
someSubexpression,
unifyDenotations,
} from './operations';
import { toPlainText } from './render';

// 𝘢
const hoa = v(0, ['e']);
Expand Down Expand Up @@ -427,6 +432,20 @@ const qSome = λ(['e', 't'], [], c =>
),
);

// λ𝘗. λ𝘘. ¬∃𝘢 : 𝘗(𝘢). 𝘘(𝘢)
const qNone = λ(['e', 't'], [], c =>
λ(['e', 't'], c, c =>
not(
some(
'e',
c,
c => app(v(1, c), v(0, c)),
c => app(v(2, c), v(0, c)),
),
),
),
);

// λ𝘗. λ𝘘. ∀𝘢 : 𝘗(𝘢). 𝘘(𝘢)
const qEvery = λ(['e', 't'], [], c =>
λ(['e', 't'], c, c =>
Expand All @@ -439,12 +458,173 @@ const qEvery = λ(['e', 't'], [], c =>
),
);

// λ𝘗. λ𝘘. ∀.SING 𝘢 : 𝘗(𝘢). 𝘘(𝘢)
const qEach = λ(['e', 't'], [], c =>
λ(['e', 't'], c, c =>
everySing(
'e',
c,
c => app(v(1, c), v(0, c)),
c => app(v(2, c), v(0, c)),
),
),
);

// λ𝘗. λ𝘘. ∀.CUML 𝘢 : 𝘗(𝘢). 𝘘(𝘢)
const qAll = λ(['e', 't'], [], c =>
λ(['e', 't'], c, c =>
everyCuml(
'e',
c,
c => app(v(1, c), v(0, c)),
c => app(v(2, c), v(0, c)),
),
),
);

// λ𝘗. λ𝘘. GEN 𝘢 : 𝘗(𝘢). 𝘘(𝘢)
const qGen = λ(['e', 't'], [], c =>
λ(['e', 't'], c, c =>
gen(
'e',
c,
c => app(v(1, c), v(0, c)),
c => app(v(2, c), v(0, c)),
),
),
);

// λ𝘗 : 𝘗(a). λ𝘘. 𝘘(a) | ¬∃𝘦. τ(𝘦) <.near t0 ∧ meakuq.w(a)(𝘦)
const qExo = presuppose(
λ(
['e', 't'],
['e'],
c => λ(['e', 't'], c, c => app(v(0, c), v(2, c))),
c => app(v(0, c), v(1, c)),
),
not(
some('v', ['e'], c =>
and(
beforeNear(app(temporalTrace(c), v(0, c)), speechTime(c)),
verb('meakuq', [v(1, c)], v(0, c), realWorld(c)),
),
),
),
);

// λ𝘗 : 𝘗(a). λ𝘘. 𝘘(a) | ∃𝘦. τ(𝘦) <.near t0 ∧ meakuq.w(a)(𝘦)
const qEndo = presuppose(
λ(
['e', 't'],
['e'],
c => λ(['e', 't'], c, c => app(v(0, c), v(2, c))),
c => app(v(0, c), v(1, c)),
),
some('v', ['e'], c =>
and(
beforeNear(app(temporalTrace(c), v(0, c)), speechTime(c)),
verb('meakuq', [v(1, c)], v(0, c), realWorld(c)),
),
),
);

// λ𝘗 : 𝘗(a). λ𝘘. 𝘘(a) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nıka.w(a)(𝘦)
const qDem = presuppose(
λ(
['e', 't'],
['e'],
c => λ(['e', 't'], c, c => app(v(0, c), v(2, c))),
c => app(v(0, c), v(1, c)),
),
some('v', ['e'], c =>
and(
subinterval(app(temporalTrace(c), v(0, c)), speechTime(c)),
and(
equals(app(app(agent(c), v(0, c)), realWorld(c)), ji(c)),
verb('nıka', [v(1, c)], v(0, c), realWorld(c)),
),
),
),
);

// λ𝘗 : 𝘗(a). λ𝘘. 𝘘(a) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nıka.w(a)(𝘦) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ tıjuı.w(a, jí)(𝘦)
const qProx = presuppose(
presuppose(
λ(
['e', 't'],
['e'],
c => λ(['e', 't'], c, c => app(v(0, c), v(2, c))),
c => app(v(0, c), v(1, c)),
),
some('v', ['e'], c =>
and(
subinterval(app(temporalTrace(c), v(0, c)), speechTime(c)),
and(
equals(app(app(agent(c), v(0, c)), realWorld(c)), ji(c)),
verb('nıka', [v(1, c)], v(0, c), realWorld(c)),
),
),
),
),
some('v', ['e'], c =>
and(
subinterval(app(temporalTrace(c), v(0, c)), speechTime(c)),
verb('tıjuı', [v(1, c), ji(c)], v(0, c), realWorld(c)),
),
),
);

// λ𝘗 : 𝘗(a). λ𝘘. 𝘘(a) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ AGENT(𝘦)(w) = jí ∧ nıka.w(a)(𝘦) | ∃𝘦. τ(𝘦) ⊆ t0 ∧ tıjao.w(a, jí)(𝘦)
const qDist = presuppose(
presuppose(
λ(
['e', 't'],
['e'],
c => λ(['e', 't'], c, c => app(v(0, c), v(2, c))),
c => app(v(0, c), v(1, c)),
),
some('v', ['e'], c =>
and(
subinterval(app(temporalTrace(c), v(0, c)), speechTime(c)),
and(
equals(app(app(agent(c), v(0, c)), realWorld(c)), ji(c)),
verb('nıka', [v(1, c)], v(0, c), realWorld(c)),
),
),
),
),
some('v', ['e'], c =>
and(
subinterval(app(temporalTrace(c), v(0, c)), speechTime(c)),
verb('tıjao', [v(1, c), ji(c)], v(0, c), realWorld(c)),
),
),
);

function denoteQuantifier(value: CovertValue): Expr {
switch (value) {
case '[∃]':
case '':
return qSome;
case '[∀]':
case '¬∃':
return qNone;
case '∀':
return qEvery;
case '∀.SING':
return qEach;
case '∀.CUML':
return qAll;
case 'GEN':
return qGen;
case 'EXO':
return qExo;
case 'ENDO':
return qEndo;
case 'DEM':
return qDem;
case 'PROX':
return qProx;
case 'DIST':
return qDist;
default:
throw new Unrecognized(`quantifier: ${value}`);
}
Expand Down
31 changes: 30 additions & 1 deletion src/semantics/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NonVerbEntry, VerbEntry } from '../dictionary';
import { Impossible } from '../error';
import { Branch, Leaf } from '../tree';

Expand Down Expand Up @@ -120,6 +119,9 @@ export type Expr =
| Polarizer<'indeed'>
| Quantifier<'some'>
| Quantifier<'every'>
| Quantifier<'every_sing'>
| Quantifier<'every_cuml'>
| Quantifier<'gen'>
| Infix<'equals', 't'>
| TimeRelation<'subinterval'>
| TimeRelation<'before'>
Expand Down Expand Up @@ -408,6 +410,33 @@ export function every(
return quantifier('every', domain, context, body, restriction);
}

export function everySing(
domain: ExprType,
context: ExprType[],
body: (context: ExprType[]) => Expr,
restriction?: (context: ExprType[]) => Expr,
): Expr {
return quantifier('every_sing', domain, context, body, restriction);
}

export function everyCuml(
domain: ExprType,
context: ExprType[],
body: (context: ExprType[]) => Expr,
restriction?: (context: ExprType[]) => Expr,
): Expr {
return quantifier('every_cuml', domain, context, body, restriction);
}

export function gen(
domain: ExprType,
context: ExprType[],
body: (context: ExprType[]) => Expr,
restriction?: (context: ExprType[]) => Expr,
): Expr {
return quantifier('gen', domain, context, body, restriction);
}

export function equals(left: Expr, right: Expr): Expr {
assertTypesEqual(left.type, right.type);
assertContextsEqual(left.context, right.context);
Expand Down
6 changes: 6 additions & 0 deletions src/semantics/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ const plainText: Format = {
quantifierSymbols: {
some: '∃',
every: '∀',
every_sing: '∀.SING ',
every_cuml: '∀.CUML ',
gen: 'GEN ',
lambda: 'λ',
},
quantifier: (symbol, name, body) => `${symbol}${name}. ${body}`,
Expand Down Expand Up @@ -302,6 +305,9 @@ const latex: Format = {
quantifierSymbols: {
some: '\\exists',
every: '\\forall',
every_sing: '\\forall_{\\textsc{sing}}',
every_cuml: '\\forall_{\\textsc{cuml}}',
gen: '\\textsc{gen}\\ ',
lambda: '\\lambda',
},
quantifier: (symbol, name, body) => `${symbol} ${name}.\\ ${body}`,
Expand Down
Loading

0 comments on commit f7e06cc

Please sign in to comment.