Exemple #1
0
    def run():

        usage = "usage: %prog --lemme LEMME [ --tags TAG1[,TAG2...]]";
        parser = OptionParser(usage);

        #input mode
        parser.add_option(
            '--lemme',
            dest="lemme",
            help="the lemme to inflect",
            metavar="LEMME"
        );

        parser.add_option(
            '--tags',
            dest="tagsArg",
            help="the tags, separated by comma",
            metavar="TAG"
        );



        (options, args) = parser.parse_args();


        dictParser = DictionnaryParser("fra");
        dictParser.generate_graph();

        lemme = options.lemme;
        tags = set(options.tagsArg.split(','));
        print(Generator.generate_word(lemme, tags, dictParser.graph));
Exemple #2
0
    def run():

        usage = "usage: %prog --word ";
        parser = OptionParser(usage);

        #input mode
        parser.add_option(
            '--word',
            dest="flexion",
            help="the word to decompose",
            metavar="WORD"
        );

        (options, args) = parser.parse_args();

        dictParser = DictionnaryParser("fra");
        dictParser.generate_graph();
        flexion = options.flexion;

        print(Lexer.analyse_word(flexion, dictParser.graph));
Exemple #3
0
	def parse(self):
		"""Decompose the sentence."""

		dictParser = DictionnaryParser(self.lang)
		dictParser.generate_graph()
		words = self.original_text.split(" ")

		#decomposedWords = []
		for word in words:
			try :
				dictParser.graph[word]
			except KeyError:
				#if we face an unknown word we mark it 
				self._decomposedWords.append((word,"unknown"))
				continue
			decompositions = Lexer.analyse_word(word, dictParser.graph)
			self._decomposedWords.append((word,decompositions))

		# debug message
		logger.debug(self._decomposedWords)