About
Last edited: August 8, 2025Welcome to the personal site of Houjun “Jack” Liu.
I’m on the blaggosphere as u/jemoka and @jemoka.
Who’s this guy?
I am a human interested in linguistic analysis, NLP, and user interfaces. I think AGI & Emacs are cool. I run Shabang, do research in NLP and model-based RL, and am working for TalkBank on the intersection between speech and language.
I’m currently doing my undergrad at Stanford, where I write some code for Stanza, a NLP package for many human languages, and a rover that we are sending to Antarctica.
Absolute Value Function
Last edited: August 8, 2025Here’s a fun implementation of absolute value.
long abs_value(long num) {
long sign = num >> (sizeof(long)*CHAR_BIT - 1); // so you only get all 1s or all 0s
return (num ^ sign) - sign; // sign is either -1 or 0. So, if num is non-negative
// num^sign is not going to do anything (as 0^0 = 0, 0^1 = 1).
// If num negative, num^sign is going to flip the bit AND subtract
// negative on (i.e. add one)
}
abstract syntax tree
Last edited: August 8, 2025abstract syntax tree is what happens when CFGs is applied to text (i.e., the parser traces the AST in time).
Building an AST
Generally, each production will have an action, which is the relevant computation.
X -> Y1... Yn { action }
Each symbol X admits an attribute X.val
- for each terminal,
valis the associated lexeme - for non-terminals,
valis the expression’s value (i.e., from the values of the subexpressions)
you job is to compose the subexpressions’ values and stick it into X.val. Notably, cycles are not allowed because we typically parse bottom-up, left ot right.
acadm
Last edited: August 8, 2025accounting price
Last edited: August 8, 2025To determine
