1 | lib 1008485 // stanford parser |
2 | lib 1008486 // english model |
3 | |
4 | import edu.stanford.nlp.ling.CoreLabel; |
5 | import edu.stanford.nlp.process.TokenizerFactory; |
6 | import edu.stanford.nlp.parser.lexparser.LexicalizedParser; |
7 | import edu.stanford.nlp.process.CoreLabelTokenFactory; |
8 | import edu.stanford.nlp.process.PTBTokenizer; |
9 | import edu.stanford.nlp.process.Tokenizer; |
10 | import edu.stanford.nlp.trees.Tree; |
11 | |
12 | static TokenizerFactory<CoreLabel> stanfordParseEnglish_tokenizerFactory; |
13 | static LexicalizedParser stanfordParseEnglish_parser; |
14 | sS stanfordParseEnglish_PCG_MODEL = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"; |
15 | |
16 | static Tree stanfordParseEnglish(S s) {
|
17 | synchronized(stanfordParseEnglish_PCG_MODEL) {
|
18 | if (stanfordParseEnglish_tokenizerFactory == null) {
|
19 | stanfordParseEnglish_tokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "invertible=true"); |
20 | stanfordParseEnglish_parser = LexicalizedParser.loadModel(stanfordParseEnglish_PCG_MODEL); |
21 | } |
22 | } |
23 | ret stanfordParseEnglish_parser.apply( |
24 | stanfordParseEnglish_tokenizerFactory.getTokenizer(new StringReader(s)).tokenize()); |
25 | } |
Began life as a copy of #1008487
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008491 |
| Snippet name: | stanfordParseEnglish |
| Eternal ID of this version: | #1008491/5 |
| Text MD5: | 4c0292202db5f7681767bb8509a21671 |
| Author: | stefan |
| Category: | javax / a.i. parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-05-19 14:10:29 |
| Source code size: | 1137 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 662 / 717 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |