def tagRawSentence(self, DICT, rawLine):
     line = VnInitTagger4Sentence(DICT, rawLine)
     sen = ''
     wordTags = line.replace("“", "''").replace("”", "''").replace("\"", "''").split()
     for i in (range(len(wordTags))):
         fwObject = FWObject.getFWObject(wordTags, i)
         word, tag = getWordTag(wordTags[i])
         node = self.findFiredNode(fwObject)
         sen += word + "/" + node.conclusion + " "
     return sen.strip()
Exemple #2
0
 def tagRawSentence(self, DICT, rawLine):
     line = InitTagger4Sentence(DICT, rawLine)
     sen = ""
     wordTags = line.replace("“", "''").replace("”", "''").replace('"', "''").split()
     for i in range(len(wordTags)):
         fwObject = FWObject.getFWObject(wordTags, i)
         word, tag = getWordTag(wordTags[i])
         node = self.findFiredNode(fwObject)
         if node.depth > 0:
             sen += word + "/" + node.conclusion + " "
         else:  # Fired at root, return initialized tag
             sen += word + "/" + tag + " "
     return sen.strip()
Exemple #3
0
def getCondition(strCondition):
    condition = FWObject(False)
    for rule in strCondition.split(" and "):
        rule = rule.strip()
        key = rule[rule.find(".") + 1 : rule.find(" ")]
        value = getConclusion(rule)
        #print rule, key, value     
        if key == "prevWord2": 
            condition.context[0] = value
        elif key == "prevTag2":
            condition.context[1] = value
        elif key == "prevWord1":
            condition.context[2] = value
        elif key == "prevTag1":
            condition.context[3] = value
        elif key == "word":
            condition.context[4] = value
        elif key == "tag":
            condition.context[5] = value
        elif key == "nextWord1":
            condition.context[6] = value
        elif key == "nextTag1":
            condition.context[7] = value
        elif key == "nextWord2":
            condition.context[8] = value
        else:
            condition.context[9] = value
    #print condition.toStr()
    return condition