Skip to content

Commit 6cc511e

Browse files
author
Daniel Khashabi
committed
Update LBJLANGUAGE.md
1 parent a4dcce2 commit 6cc511e

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

lbjava/doc/LBJLANGUAGE.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The LBJ Language
1+
# 4 The LBJ Language
22
Now that we have defined the building blocks of classifier computation, we next describe LBJ’s
33
syntax and semantics for programming with these building blocks.
44

@@ -8,7 +8,7 @@ inferences. Each will be translated by the LBJ compiler into a Java class of the
88
the package declaration is present, those Java classes will all become members of that package.
99
Import declarations perform the same function in an LBJ source file as in a Java source file.
1010

11-
## Classifiers
11+
## 4.1 Classifiers
1212

1313
In LBJ, a classifier can be defined with Java code or composed from the definitions of other
1414
classifiers using special operators. As such, the syntax of classifier specification allows the programmer
@@ -17,7 +17,7 @@ syntax of classifier specification more precisely, including the syntax of class
1717
data. It also details the behavior of the LBJ compiler when classifiers are specified in terms of
1818
training data and when changes are made to an LBJ source file.
1919

20-
### Classifier Declarations
20+
### 4.1.1 Classifier Declarations
2121

2222
Classifier declarations are used to name classifier expressions (discussed in Section 4.1.2). The
2323
syntax of a classifier declaration has the following form:
@@ -155,7 +155,7 @@ extraction. The optional `from` clause designates a parser used to provide train
155155
learnMe at compile-time. Finally, the optional `with` clause designates a particular learner for
156156
`learnMe` to utilize.
157157

158-
### Classifier Expressions
158+
### 4.1.2 Classifier Expressions
159159

160160
As was alluded to above, the right hand side of a classifier declaration is actually a single classifier
161161
expression. A classifier expression is one of the following syntactic constructs:
@@ -170,7 +170,7 @@ expression. A classifier expression is one of the following syntactic constructs
170170

171171
We have already explored examples of almost all of these. More precise definitions of each follow.
172172

173-
### Classifier Names
173+
### 4.1.2.1 Classifier Names
174174

175175
The name of a classifier defined either externally or in the same source file may appear wherever
176176
a classifier expression is expected. If the named classifier’s declaration is found in the same
@@ -181,7 +181,7 @@ at the top of the source file. The class file or Java source file containing the
181181
of an imported classifier must exist prior to running the LBJ compiler on the source file that
182182
imports it.
183183

184-
### Method Bodies
184+
### 4.1.2.2 Method Bodies
185185

186186
A method body is a list of Java statements enclosed in curly braces explicitly implementing a
187187
classifier. When the classifier implemented by the method body returns a single feature, the
@@ -192,7 +192,7 @@ body takes its argument and feature `return` type from the header of the classif
192192
is contained in (except when in the presence of a classifier cast expression, discussed in Section
193193
4.1.2.3). For more information on method bodies in LBJ, see Section 4.1.3.
194194

195-
#### Classifier Cast Expressions
195+
#### 4.1.2.3 Classifier Cast Expressions
196196

197197
When the programmer wishes for a classifier sub-expression on the right hand side of a classifier
198198
declaration to be implemented with a feature return type differing from that defined in the
@@ -216,7 +216,7 @@ When a classifier cast expression is applied to a classifier expression that con
216216
classifier expressions, the cast propagates down to those classifier expressions recursively as well.
217217

218218

219-
#### Conjunctions
219+
#### 4.1.2.4 Conjunctions
220220

221221
A conjunction is written with the double ampersand operator (`&&`) in between two classifier
222222
expressions (see Figure 4.1 for an example). The conjunction of two classifiers results in a new
@@ -240,13 +240,13 @@ Finally, the conjunction of a feature generator with any other classifier will r
240240
generator producing features representing the combination of every pairing of features from the
241241
two argument classifiers.
242242

243-
#### Composite Generators
243+
#### 4.1.2.5 Composite Generators
244244

245245
“Composite generator” is LBJ terminology for a comma separated list of classifier expressions.
246246
When classifier expressions are listed separated by commas, the result is a feature generator that
247247
simply returns all the features returned by each classifier in the list.
248248

249-
#### Learning Classifier Expressions
249+
#### 4.1.2.6 Learning Classifier Expressions
250250

251251
Learning classifier expressions have the following syntax:
252252

@@ -375,7 +375,7 @@ a `.lc` extension (“`lc`” stands for “learning classifier”). The directo
375375
the lexicon and example files mentioned earlier are written depends on the appearance of certain
376376
command line parameters discussed in Section 6.2.
377377

378-
#### Inference Invocations
378+
#### 4.1.2.7 Inference Invocations
379379

380380
Inference is the process through which classifiers constrained in terms of each other reconcile
381381
their outputs. More information on the specification of constraints and inference procedures can
@@ -392,7 +392,7 @@ that respects the constraints of the inference may be named as follows:
392392
discrete ChunkType(Chunk c) <- ChunkInference(LocalChunkType)
393393
```
394394

395-
### Method Bodies
395+
### 4.1.3 Method Bodies
396396

397397
Depending on the feature `return` type, the programmer will have differing needs when designing
398398
a method body. If the feature `return` type is either `discrete` or `real`, then only the value of
@@ -408,7 +408,7 @@ intended to provide information within the programmer’s own code, either in th
408408
in other classifier method bodies. In these situations, the features’ values (and not their names)
409409
are the data of interest. Section 4.1.3.2 discusses a special semantics for classifier invocation.
410410

411-
#### The `sense` Statement
411+
#### 4.1.3.1 The `sense` Statement
412412

413413
The `sense` statement is used to indicate that the name and/or value of a feature has been
414414
detected when computing an array of features or a feature generator. In these contexts, any
@@ -442,7 +442,7 @@ resulting value will be converted to a `String`.
442442
method body. In this case, the expression represents the feature’s name, and that feature is
443443
assumed to be Boolean with a value of `true`.
444444

445-
#### Invoking Classifiers
445+
#### 4.1.3.2 Invoking Classifiers
446446
Under the right circumstances, any classifier may be invoked inside an LBJ method body just as
447447
if it were a method. The syntax of a classifier invocation is simply `name (object )`, where `object`
448448
is the object to be classified and `name` follows the same rules as when a classifier is named in
@@ -473,15 +473,15 @@ resulting value will be converted to a `String`.
473473
the colon are prepended to every feature’s name. Thus, an entire set of features can be
474474
translated to describe a different context with a single `sense` statement.
475475

476-
#### Syntax Limitations
476+
#### 4.1.3.3 Syntax Limitations
477477

478478
When the exact computation is known, LBJ intends to allow the programmer to explicitly
479479
define a classifier using arbitrary Java. However, the current version of LBJ suffers from one
480480
major limitation. All J2SE 1.4.2 statement and expression syntax is accepted, excluding class
481481
and interface definitions. In particular, this means that anonymous classes currently cannot be
482482
defined or instantiated inside an LBJ method body.
483483

484-
## Constraints
484+
## 4.2 Constraints
485485
Many modern applications involve the repeated application of one or more learning classifiers in
486486
a coordinated decision making process. Often, the nature of this decision making process restricts
487487
the output of each learning classifier on a call by call basis to make all these outputs coherent
@@ -500,7 +500,7 @@ simply declaring an LBJ constraint has no effect on the classifiers involved. Se
500500
introduces the syntax and semantics of LBJ inference procedures, which can then be invoked (as
501501
described in Section 4.1.2.7) to produce new classifiers that respect the constraints.
502502

503-
### Constraint Statements
503+
### 4.2.1 Constraint Statements
504504

505505
LBJ constraints are written as arbitrary first order Boolean logic expressions in terms of learning
506506
classifiers and the objects in a Java application. The LBJ constraint statement syntax is
@@ -553,7 +553,7 @@ an argument to either type of predicate are constants in the inference procedure
553553
in particular, expressions that include a learning classifier invocation as a subexpression. These
554554
learning classifier invocations are not treated as inference variables.
555555

556-
### Constraint Declarations
556+
### 4.2.2 Constraint Declarations
557557

558558
An LBJ constraint declaration declares a Java method whose purpose is to locate the objects
559559
involved in the inference and generate the constraints. Syntactically, an LBJ constraint declaration
@@ -583,7 +583,7 @@ Thus, a constraint may be invoked as if it were a Java method (i.e., without the
583583
in Section 4.2.1) anywhere in an LBJ source file, just like a classifier. Such an invocation
584584
will evaluate the constraint in place, rather than constructing its first order representation.
585585

586-
## Inference
586+
## 4.3 Inference
587587

588588
The syntax of an LBJ inference has the following form:
589589

@@ -635,7 +635,6 @@ SomeLearner normalizedby Sigmoid;
635635
normalizedby Softmax;
636636
```
637637

638-
639638
These normalizer clauses written in any order specify that the `SomeLearner` learning classifier
640639
should have its scores normalized with the `Sigmoid` normalization method and that all other
641640
learning classifiers involved in the inference should be normalized by `Softmax`.
@@ -661,7 +660,7 @@ The `subjectto` clause may also contain arbitrary Java, just like any other cons
661660
Finally, the `with` clause specifies which inference algorithm to use. It functions similarly to
662661
the `with` clause of a learning classifier expression (see Section 4.1.2.6).
663662

664-
## “Makefile” Behavior
663+
## 4.4 “Makefile” Behavior
665664

666665
An LBJ source file also functions as a makefile in the following sense. First, code will only be
667666
generated for a classifier definition when it is determined that a change has been made5

0 commit comments

Comments
 (0)