예제 #1
0
 def setUp(self):
     io = CKYIO('../../../resources/GRAMMAR.IN',
                '../../../resources/LEXICON.IN',
                '../../../resources/SENTENCES.IN')
     outfile = 'OUTFILE.'
     self.parser = CKY(io.readGrammar(), io.readLexicon(), outfile)
     self.parser.matrix = []
     self.parser.initializeTable(4)
예제 #2
0
                        action="store_false",
                        dest="DEBUG",
                        default=True,
                        help="don't print the chart content  [default True]")
    args = parser.parse_args()

    #call parser
    # Theory of call:
    #        - args.dest : contains content user entered
    #        - e.g: args.grammar will return file name of file contain grammar
    if args:
        try:
            #Call to main parser
            #Read files
            if (args.algorithm == "c"):
                io = CKYIO(args.grammar, args.lexicon, args.sentence)
                listGrammar = io.readGrammar()
                listLexicon = io.readLexicon()
                listSentence = io.readSentence()
                #End read files

                #Initialize CYK
                cykInstance = CKY(listGrammar, listLexicon, args.outfile)
                startTime = time.clock()
                #Parse for each sentence INPUT
                for sent in listSentence:
                    cykInstance.syntacticAnalyzer(sent)
                #End parse
                stopTime = time.clock()
                print "Analysis success. " \
                      "Please check output file! \nTime is: " \
예제 #3
0
 def setUp(self):
     self.io = CKYIO('../../../resources/GRAMMAR.IN', \
                  '../../../resources/LEXICON.IN', \
                  '../../../resources/SENTENCES.IN')