Generating forms

Published

June 8, 2024

Example with a string-backed parser

Make a string-backed parser.

Make a StringParser
using CitableParserBuilder
parser = CitableParserBuilder.gettysburgParser(repo) |> StringParser

Generate a full analysis with token from a lexeme and a morphological form. The result will be a (possibly empty) vector of analyses.

lex = LexemeUrn("gburglex.come")
mform = FormUrn("pennpos.VBN")
matches = generate(lex, mform, parser)
1-element Vector{Analysis}:
 Analysis("come", gburglex.come, pennpos.VBN, gburgstem.come, gburgrule.pennid)

Use the token function to extract surface tokens (here, using Julia broadcasting).

token.(matches)
1-element Vector{SubString{String}}:
 "come"

Example with a dataframe-backed parser

DFParsers work exactly the same way. Convert a string-backed parser to a dataframe-backed parser.

dfp = DFParser(parser)
generate(lex, mform, dfp)  .|> token
1-element Vector{InlineStrings.String15}:
 "come"
generate(lex, mform, dfp)  == generate(lex,mform, parser)
true