# Path: Linker.py
# class Ui_MainWindow(object):
#     def setupUi(self, MainWindow):
#         MainWindow.setObjectName("MainWindow")
#         MainWindow.resize(1372, 701)
#         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
#         sizePolicy.setHorizontalStretch(0)
#         sizePolicy.setVerticalStretch(0)
#         sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
#         MainWindow.setSizePolicy(sizePolicy)
#         self.centralwidget = QtWidgets.QWidget(MainWindow)
#         self.centralwidget.setObjectName("centralwidget")
#         self.tableView = QtWidgets.QTableView(self.centralwidget)
#         self.tableView.setGeometry(QtCore.QRect(10, 50, 835, 351))
#         font = QtGui.QFont()
#         font.setFamily("Arial")
#         font.setPointSize(10)
#         self.tableView.setFont(font)
#         self.tableView.setObjectName("tableView")
#         self.OKButton = QtWidgets.QPushButton(self.centralwidget)
#         self.OKButton.setGeometry(QtCore.QRect(260, 400, 90, 25))
#         self.OKButton.setObjectName("OKButton")
#         self.CancelButton = QtWidgets.QPushButton(self.centralwidget)
#         self.CancelButton.setGeometry(QtCore.QRect(390, 400, 90, 25))
#         self.CancelButton.setObjectName("CancelButton")
#         self.targetLexCombo = QtWidgets.QComboBox(self.centralwidget)
#         self.targetLexCombo.setGeometry(QtCore.QRect(160, 10, 361, 29))
#         font = QtGui.QFont()
#         font.setPointSize(10)
#         self.targetLexCombo.setFont(font)
#         self.targetLexCombo.setLayoutDirection(QtCore.Qt.LeftToRight)
#         self.targetLexCombo.setObjectName("targetLexCombo")
#         self.ShowOnlyUnlinkedCheckBox = QtWidgets.QCheckBox(self.centralwidget)
#         self.ShowOnlyUnlinkedCheckBox.setGeometry(QtCore.QRect(550, 10, 121, 27))
#         self.ShowOnlyUnlinkedCheckBox.setObjectName("ShowOnlyUnlinkedCheckBox")
#         self.label = QtWidgets.QLabel(self.centralwidget)
#         self.label.setGeometry(QtCore.QRect(10, 10, 151, 23))
#         self.label.setObjectName("label")
#         self.HideProperNounsCheckBox = QtWidgets.QCheckBox(self.centralwidget)
#         self.HideProperNounsCheckBox.setGeometry(QtCore.QRect(710, 10, 121, 27))
#         self.HideProperNounsCheckBox.setObjectName("HideProperNounsCheckBox")
#         MainWindow.setCentralWidget(self.centralwidget)
#         self.menubar = QtWidgets.QMenuBar(MainWindow)
#         self.menubar.setGeometry(QtCore.QRect(0, 0, 1372, 21))
#         self.menubar.setObjectName("menubar")
#         MainWindow.setMenuBar(self.menubar)
#         self.statusbar = QtWidgets.QStatusBar(MainWindow)
#         self.statusbar.setObjectName("statusbar")
#         MainWindow.setStatusBar(self.statusbar)
# 
#         self.retranslateUi(MainWindow)
#         QtCore.QMetaObject.connectSlotsByName(MainWindow)
# 
#     def retranslateUi(self, MainWindow):
#         _translate = QtCore.QCoreApplication.translate
#         MainWindow.setWindowTitle(_translate("MainWindow", "FLExTrans Sense Linker Tool"))
#         self.OKButton.setText(_translate("MainWindow", "OK"))
#         self.CancelButton.setText(_translate("MainWindow", "Cancel"))
#         self.targetLexCombo.setToolTip(_translate("MainWindow", "After selecting the desired sense here, double-click in the target head word column for the desired row to copy it."))
#         self.ShowOnlyUnlinkedCheckBox.setText(_translate("MainWindow", "Show Only Unlinked"))
#         self.label.setText(_translate("MainWindow", "All Target Senses:"))
#         self.HideProperNounsCheckBox.setText(_translate("MainWindow", "Hide Proper Nouns"))


import re
import sys
import unicodedata
import ReadConfig
import Utils
from fuzzywuzzy import fuzz
from System import Guid
from System import String
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
from FTModuleClass import *                                                 
from FTModuleClass import FlexToolsModuleClass
from SIL.LCModel import *                                                   
from SIL.LCModel.Core.KernelInterfaces import ITsString, ITsStrBldr         
from SIL.LCModel.DomainServices import SegmentServices
from flexlibs.FLExProject import FLExProject, GetProjectNames
from Linker import Ui_MainWindow






#----------------------------------------------------------------
# Configurables:
PROPER_NOUN_ABBREV = 'nprop'
DUMP_VOCAB_WORDS = False


# The minimum length a word should have before doing a fuzzy compare
# otherwise an exact comparision is used
MIN_GLOSS_LEN_FOR_FUZZ = 5
# Only do a fuzzy compare if the difference in the lengths of the strings
# is less than this number
MIN_DIFF_GLOSS_LEN_FOR_FUZZ = 3
# The percentage or higher in similarity that two words must have in  
# order to be outputted as a possible match. 
FUZZ_THRESHOLD = 74

#----------------------------------------------------------------
# Documentation that the user sees:

docs = {FTM_Name       : "Sense Linker Tool",
        FTM_Version    : "3.4.1",
        FTM_ModifiesDB : True,
        FTM_Synopsis   : "Link source and target senses.",
        FTM_Help   : "",

# Path: Linker.py
# class Ui_MainWindow(object):
#     def setupUi(self, MainWindow):
#         MainWindow.setObjectName("MainWindow")
#         MainWindow.resize(1372, 701)
#         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
#         sizePolicy.setHorizontalStretch(0)
#         sizePolicy.setVerticalStretch(0)
#         sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
#         MainWindow.setSizePolicy(sizePolicy)
#         self.centralwidget = QtWidgets.QWidget(MainWindow)
#         self.centralwidget.setObjectName("centralwidget")
#         self.tableView = QtWidgets.QTableView(self.centralwidget)
#         self.tableView.setGeometry(QtCore.QRect(10, 50, 835, 351))
#         font = QtGui.QFont()
#         font.setFamily("Arial")
#         font.setPointSize(10)
#         self.tableView.setFont(font)
#         self.tableView.setObjectName("tableView")
#         self.OKButton = QtWidgets.QPushButton(self.centralwidget)
#         self.OKButton.setGeometry(QtCore.QRect(260, 400, 90, 25))
#         self.OKButton.setObjectName("OKButton")
#         self.CancelButton = QtWidgets.QPushButton(self.centralwidget)
#         self.CancelButton.setGeometry(QtCore.QRect(390, 400, 90, 25))
#         self.CancelButton.setObjectName("CancelButton")
#         self.targetLexCombo = QtWidgets.QComboBox(self.centralwidget)
#         self.targetLexCombo.setGeometry(QtCore.QRect(160, 10, 361, 29))
#         font = QtGui.QFont()
#         font.setPointSize(10)
#         self.targetLexCombo.setFont(font)
#         self.targetLexCombo.setLayoutDirection(QtCore.Qt.LeftToRight)
#         self.targetLexCombo.setObjectName("targetLexCombo")
#         self.ShowOnlyUnlinkedCheckBox = QtWidgets.QCheckBox(self.centralwidget)
#         self.ShowOnlyUnlinkedCheckBox.setGeometry(QtCore.QRect(550, 10, 121, 27))
#         self.ShowOnlyUnlinkedCheckBox.setObjectName("ShowOnlyUnlinkedCheckBox")
#         self.label = QtWidgets.QLabel(self.centralwidget)
#         self.label.setGeometry(QtCore.QRect(10, 10, 151, 23))
#         self.label.setObjectName("label")
#         self.HideProperNounsCheckBox = QtWidgets.QCheckBox(self.centralwidget)
#         self.HideProperNounsCheckBox.setGeometry(QtCore.QRect(710, 10, 121, 27))
#         self.HideProperNounsCheckBox.setObjectName("HideProperNounsCheckBox")
#         MainWindow.setCentralWidget(self.centralwidget)
#         self.menubar = QtWidgets.QMenuBar(MainWindow)
#         self.menubar.setGeometry(QtCore.QRect(0, 0, 1372, 21))
#         self.menubar.setObjectName("menubar")
#         MainWindow.setMenuBar(self.menubar)
#         self.statusbar = QtWidgets.QStatusBar(MainWindow)
#         self.statusbar.setObjectName("statusbar")
#         MainWindow.setStatusBar(self.statusbar)
# 
#         self.retranslateUi(MainWindow)
#         QtCore.QMetaObject.connectSlotsByName(MainWindow)
# 
#     def retranslateUi(self, MainWindow):
#         _translate = QtCore.QCoreApplication.translate
#         MainWindow.setWindowTitle(_translate("MainWindow", "FLExTrans Sense Linker Tool"))
#         self.OKButton.setText(_translate("MainWindow", "OK"))
#         self.CancelButton.setText(_translate("MainWindow", "Cancel"))
#         self.targetLexCombo.setToolTip(_translate("MainWindow", "After selecting the desired sense here, double-click in the target head word column for the desired row to copy it."))
#         self.ShowOnlyUnlinkedCheckBox.setText(_translate("MainWindow", "Show Only Unlinked"))
#         self.label.setText(_translate("MainWindow", "All Target Senses:"))
#         self.HideProperNounsCheckBox.setText(_translate("MainWindow", "Hide Proper Nouns"))


# Path: LinkSenseTool.py
import re
import sys
import unicodedata
import ReadConfig
import Utils
from fuzzywuzzy import fuzz
from System import Guid
from System import String
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
from FTModuleClass import *                                                 
from FTModuleClass import FlexToolsModuleClass
from SIL.LCModel import *                                                   
from SIL.LCModel.Core.KernelInterfaces import ITsString, ITsStrBldr         
from SIL.LCModel.DomainServices import SegmentServices
from flexlibs.FLExProject import FLExProject, GetProjectNames
from Linker import Ui_MainWindow







#----------------------------------------------------------------
# Configurables:
PROPER_NOUN_ABBREV = 'nprop'
DUMP_VOCAB_WORDS = False


# The minimum length a word should have before doing a fuzzy compare
# otherwise an exact comparision is used
MIN_GLOSS_LEN_FOR_FUZZ = 5
# Only do a fuzzy compare if the difference in the lengths of the strings
# is less than this number
MIN_DIFF_GLOSS_LEN_FOR_FUZZ = 3
# The percentage or higher in similarity that two words must have in  
# order to be outputted as a possible match. 
FUZZ_THRESHOLD = 74

#----------------------------------------------------------------
# Documentation that the user sees:

docs = {FTM_Name       : "Sense Linker Tool",
        FTM_Version    : "3.4.1",
        FTM_ModifiesDB : True,
        FTM_Synopsis   : "Link source and target senses.",
        FTM_Help   : "",

        FTM_Description:  