Libraryless. Click here for Pure Java version (13119L/91K).
1 | // e.g."if a snippet contains token X, it also contains token Y"; |
2 | // returns an iterator of NLA blocks (one for each possible mapping) |
3 | static ItIt<S> ai_pronounResolvedToNLA(S s) {
|
4 | AI_PronounResolver1 resolver = new(s); |
5 | resolver.run(); |
6 | print("nounPhrases", resolver.nounPhrases);
|
7 | print("pronouns", resolver.pronouns);
|
8 | |
9 | // mapping: pronoun -> noun phrase |
10 | ret mapI(resolver.allMappings(), mapping -> {
|
11 | L<ParsedWithTokens> pwt = replaceElementsUsingMap(resolver.pwt, (Map) mapping); |
12 | pnl(pwt); |
13 | CountingVarMaker varMaker = new("entity");
|
14 | new LS lines; |
15 | new Map<ParsedWithTokens, S> entityNames; |
16 | for (ParsedWithTokens p : values(mapping)) {
|
17 | S name = varMaker!; |
18 | entityNames.put(p, name); |
19 | //lines.add("there is " + getVar_rec(p) + " " + name);
|
20 | lines.add("there is " + name);
|
21 | lines.add(name + " is " + getVar_rec(p)); |
22 | } |
23 | S prop = joinMap(pwt, p -> str(or(entityNames.get(p), getVar_rec(p)))); |
24 | lines.add(prop); |
25 | ret lines(lines); |
26 | }); |
27 | } |
Began life as a copy of #1028862
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1028865 |
| Snippet name: | ai_pronounResolvedToNLA |
| Eternal ID of this version: | #1028865/10 |
| Text MD5: | cc8fde8f7fdf4f26f020877c8c5ade75 |
| Transpilation MD5: | 415d1317deabdc00a584d41cefb042ef |
| Author: | stefan |
| Category: | javax / nla |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-07-10 18:36:23 |
| Source code size: | 1034 bytes / 27 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 440 / 594 |
| Version history: | 9 change(s) |
| Referenced in: | [show references] |