Exemple #1
0
    def testTbx1(self):
        config = lingex_structs.PhonInputSettings(None)
        config.filepath = os.path.join(util.TESTDATA_FOLDER,
                                       "TbxPhonCorpus.xml")
        config.phoneticWS = ""
        config.isLexemePhonetic = False
        xmlReader = phon_reader.PhonReader(self.unoObjs, self.userVars, config)
        self.assertEqual(xmlReader.get_filetype(), "xml")

        exampleDict = xmlReader.read()
        self.assertTrue("JPDN21.5".lower() in exampleDict)
        phonEx = exampleDict["JPDN21.5".lower()]
        self.assertEqual(phonEx.refText, "JPDN21.5")
        self.assertEqual(phonEx.gloss, "elder sister")
        self.assertNotEqual(phonEx.phonetic, "")
        self.assertNotEqual(phonEx.phonemic, "")

        self.assertTrue("EGAN03.37".lower() in exampleDict)
        phonEx = exampleDict["EGAN03.37".lower()]
        self.assertEqual(phonEx.refText, "EGAN03.37")
        self.assertEqual(phonEx.gloss, "five")
        self.assertNotEqual(phonEx.phonetic, "")
        self.assertEqual(phonEx.phonemic, "")

        suggestions = xmlReader.getSuggestions()
        self.assertEqual(len(suggestions), 1)
        self.assertEqual(suggestions[0], "JPDN37.6")
Exemple #2
0
    def testPA(self):
        config = lingex_structs.PhonInputSettings(None)
        config.filepath = os.path.join(util.TESTDATA_FOLDER, "PAdata.paxml")
        config.phoneticWS = ""
        config.isLexemePhonetic = False
        xmlReader = phon_reader.PhonReader(self.unoObjs, self.userVars, config)
        self.assertEqual(xmlReader.get_filetype(), "paxml")

        exampleDict = xmlReader.read()
        self.assertTrue("JPDN23.1".lower() in exampleDict)
        phonEx = exampleDict["JPDN23.1".lower()]
        self.assertEqual(phonEx.refText, "JPDN23.1")
        self.assertEqual(phonEx.gloss, "unmarried cousin")
        self.assertNotEqual(phonEx.phonetic, "")
        self.assertNotEqual(phonEx.phonemic, "")

        self.assertTrue("JPDN37.4".lower() in exampleDict)
        phonEx = exampleDict["JPDN37.4".lower()]
        self.assertEqual(phonEx.refText, "JPDN37.4")
        self.assertEqual(phonEx.gloss, "")
        self.assertNotEqual(phonEx.phonetic, "")
        self.assertNotEqual(phonEx.phonemic, "")

        suggestions = xmlReader.getSuggestions()
        self.assertEqual(len(suggestions), 1)
        self.assertEqual(suggestions[0], "JPDN58.02")
Exemple #3
0
    def storeAndClose(self):
        logger.debug(util.funcName('begin'))
        outSettings = lingex_structs.PhonOutputSettings(self.userVars)
        outSettings.showBrackets = bool(
            self.dlgCtrls.checkboxBrackets.getState())
        outSettings.phonemicLeftmost = bool(
            self.dlgCtrls.optionPhonemicFirst.getState())
        outSettings.storeUserVars()

        inSettings = lingex_structs.PhonInputSettings(self.userVars)
        inSettings.filepath = self.dlgCtrls.fileControl.getText()
        inSettings.phoneticWS = self.dlgCtrls.txtWritingSys.getText()
        inSettings.isLexemePhonetic = bool(
            self.dlgCtrls.optionLexemePht.getState())
        inSettings.storeUserVars()
        try:
            self.app.verifyRefnums()
        except (exceptions.DataNotFoundError,
                exceptions.DataInconsistentError) as exc:
            ok = self.msgbox.displayOkCancel(exc.msg, *exc.msg_args)
            if not ok:
                return

        PhonologyStyles(self.unoObjs, self.userVars).createStyles()
        PhonologyTags(self.userVars).loadUserVars()
        self.dlgClose()
        logger.debug(util.funcName('end'))
Exemple #4
0
 def _getPhonologySettings(self):
     """Get file paths, style names, and other options that were
     set in the Phonology Settings dialog.
     """
     logger.debug(util.funcName('begin'))
     self.inSettings = lingex_structs.PhonInputSettings(self.userVars)
     self.inSettings.loadUserVars()
     self.outSettings = lingex_structs.PhonOutputSettings(self.userVars)
     self.outSettings.loadUserVars()
     logger.debug(util.funcName('end'))
    def storeAndClose(self):
        logger.debug(util.funcName('begin'))
        outSettings = lingex_structs.PhonOutputSettings(self.userVars)
        outSettings.showBrackets = bool(
            self.dlgCtrls.checkboxBrackets.getState())
        outSettings.phonemicLeftmost = bool(
            self.dlgCtrls.optionPhonemicFirst.getState())
        outSettings.storeUserVars()

        inSettings = lingex_structs.PhonInputSettings(self.userVars)
        inSettings.filepath = self.dlgCtrls.fileControl.getText()
        inSettings.phoneticWS = self.dlgCtrls.txtWritingSys.getText()
        inSettings.isLexemePhonetic = bool(
            self.dlgCtrls.optionLexemePht.getState())
        inSettings.storeUserVars()

        PhonologyStyles(self.unoObjs, self.userVars).createStyles()
        PhonologyTags(self.userVars).loadUserVars()
        self.dlgClose()
        logger.debug(util.funcName('end'))
 def _harvestWords(self, fileItem):
     """Harvest words from the specified file."""
     fileType = fileItem.filetype  # short variable name
     logger.debug(util.funcName(args=fileType))
     words = []
     if fileType in WordsReader.supportedNames():
         reader = WordsReader(fileItem, self.unoObjs)
         words = reader.read()
     elif fileType in SFM_Reader.supportedNames():
         reader = SFM_Reader(fileItem, self.unoObjs)
         words = reader.read()
     elif fileType in InterlinReader.supportedNames():
         config = fileitemlist.InterlinInputSettings(self.userVars)
         config.showMorphLine2 = True
         config.separateMorphColumns = True
         lingExFileItem = fileitemlist.LingExFileItem(self.userVars)
         lingExFileItem.filepath = fileItem.filepath
         config.fileList.addItem(lingExFileItem)
         reader = InterlinReader(self.unoObjs, self.userVars, config)
         words = reader.grabWords(fileItem.thingsToGrab)
     elif fileType in PhonReader.supportedNames():
         config = lingex_structs.PhonInputSettings(self.userVars)
         config.filepath = fileItem.filepath
         config.phoneticWS = fileItem.writingSystem
         config.isLexemePhonetic = True
         phonUserVars = UserVars(
             Prefix.PHONOLOGY, self.unoObjs.document, logger)
         if phonUserVars.get("FlexLexeme") == 'phonemic':
             config.isLexemePhonetic = False
         reader = PhonReader(self.unoObjs, self.userVars, config)
         words = reader.grabWords(fileItem.thingsToGrab)
     elif fileType in DocReader.supportedNames():
         settings = TextSearchSettings()
         settings.load_userVars(self.userVars)
         reader = DocReader(fileItem, self.unoObjs, settings.matchesLimit)
         words = reader.read()
     elif fileType in CalcFileReader.supportedNames():
         reader = CalcFileReader(self.unoObjs)
         reader.setFileConfig(fileItem)
         words = reader.read()
     return words
Exemple #7
0
    def testTbx2(self):
        self.userVars.store("SFMarker_Gloss", "gl123")  # doesn't exist
        config = lingex_structs.PhonInputSettings(None)
        config.filepath = os.path.join(util.TESTDATA_FOLDER,
                                       "TbxPhonCorpus.xml")
        config.phoneticWS = ""
        config.isLexemePhonetic = False
        xmlReader = phon_reader.PhonReader(self.unoObjs, self.userVars, config)

        exampleDict = xmlReader.read()
        self.assertTrue("JPDN21.5".lower() in exampleDict)
        phonEx = exampleDict["JPDN21.5".lower()]
        self.assertEqual(phonEx.refText, "JPDN21.5")
        self.assertEqual(phonEx.gloss, "")
        self.assertNotEqual(phonEx.phonetic, "")
        self.assertNotEqual(phonEx.phonemic, "")

        suggestions = xmlReader.getSuggestions()
        self.assertEqual(len(suggestions), 1)
        self.assertEqual(suggestions[0], "JPDN37.6")

        self.userVars.store("SFMarker_Gloss", "")  # reset