1 """Simple extension of a CKY parser to propagate probabilities
2 through a derivation from the tag probabilities.
3
4 This is not really a probabilistic parser, it's just a basic CKY
5 parser with some extra bits to pass probabilities up through a
6 derivation from the tags. It's designed to be used with the C&C
7 tagger, so that the results get ranked according to the probabilities
8 of the tags they came from.
9
10 """
11 """
12 ============================== License ========================================
13 Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding
14
15 This file is part of The Jazz Parser.
16
17 The Jazz Parser is free software: you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation, either version 3 of the License, or
20 (at your option) any later version.
21
22 The Jazz Parser is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with The Jazz Parser. If not, see <http://www.gnu.org/licenses/>.
29
30 ============================ End license ======================================
31
32 """
33 __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"
34
35 from jazzparser.parsers.cky.parser import CkyParser
36 from jazzparser.parsers.pcfg.tools import ProbabilisticResultListTool, ProbabilityTool, ProbabilisticChartTool
37 from jazzparser.parsers.cky.tools import ChartTool
38
39 from .chart import TagRankChart
40
41 import sys, re
42 import logging
43
44 from jazzparser import settings
45
46
47 logger = logging.getLogger("main_logger")
48
50 shell_tools = [
51 ChartTool(),
52
53 ProbabilisticResultListTool(),
54 ProbabilityTool(),
55 ProbabilisticChartTool(),
56 ]
57
61
63 vals = super(TagRankParser, self)._add_signs(offset) or []
64 for (start,end,signtup) in vals:
65 if signtup[0] is None:
66 continue
67
68 cat,tag,prob = signtup
69 cat.probability = prob
70 return vals
71
72 - def parse(self, *args, **kwargs):
85