Browse Source

Add new dictionaries (Académie 9e, 8e, 4e)

Fix typo in README, kcnrtl.ui
Add TODO
experimental
Bogdan Cordier 7 years ago
parent
commit
cce732af9a
5 changed files with 91 additions and 37 deletions
  1. 8
    8
      README
  2. 12
    0
      TODO
  3. 26
    12
      kcnrtl/gui/kcnrtl.ui
  4. 43
    15
      kcnrtl/kcnrtl.py
  5. 2
    2
      setup.py

+ 8
- 8
README View File

@@ -2,17 +2,17 @@
KCnrtl
======

:Author: Bogdan Cordier bcord@hadaly.fr
:Author: Bogdan Cordier <bcord@hadaly.fr>
:Date: 2012-10-05
:Copyright: GPLv3
:Version: 0.1
:Version: 0.2b


Description
===========

KCnrtl is a simple KDE graphical client to access the CNRTL french linguistic resources.
It offers the possibility to check the definitions, synomyms, antonyms of a given
It offers the possibility to check the definitions, synonyms, antonyms of a given
french word.

Features:
@@ -23,10 +23,10 @@ Features:

*The "AMAZING Clipboard mode" :
With the "Clipboard mode" you can easily check for a synonym/antonym and replace it in your text.
To do so, just check the "Clipboard mode" checkbox, copy in the clipboard any word, KCnrtl will do
an automatic request to the CNRTL website and you can easily copy any synomym or antonym by
just clicking on them.
Now you just have to paste it back in you text !
To do so, just check the "Clipboard mode" checkbox, copy in the clipboard any word, KCnrtl will do
an automatic request to the CNRTL website and you can easily copy any synonym or antonym by
just clicking on them.
Now you just have to paste it back in you text !

Planned features:
-----------------
@@ -39,7 +39,7 @@ Installation

Decompress the archive, you can launch the program by running kcnrtl.sh

TODO
TODO!!

Dependencies
============

+ 12
- 0
TODO View File

@@ -0,0 +1,12 @@
TODO

* Show error when word isn't found
* Allow to choose word class for antonyms and synonyms
* Add some proximity indicator for synonyms and antonyms as on the CNRTL
* Ajouter un mode de priorité pour les requête en fonction de l'onglet
* Allow to disable automatic copy when item in list is clicked
* Better css stylesheet for definitions
* Add command-line mode
* Add other dictionaries
* Save entries in file to save web request
* Maybe add foreign resources

+ 26
- 12
kcnrtl/gui/kcnrtl.ui View File

@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>605</height>
<width>379</width>
<height>540</height>
</rect>
</property>
<property name="windowTitle">
<string>KCnrtl</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<iconset resource="../resources/kcnrtl.qrc">
<normaloff>:/kcnrtl_icon.svg</normaloff>:/kcnrtl_icon.svg</iconset>
</property>
<widget class="QWidget" name="centralwidget">
@@ -32,7 +32,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -60,9 +60,16 @@
<attribute name="title">
<string>Synonymie</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListView" name="listView"/>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item>
<widget class="QListView" name="listView"/>
</item>
</layout>
</item>
</layout>
</widget>
@@ -70,9 +77,16 @@
<attribute name="title">
<string>Antonymie</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListView" name="listView_2"/>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="comboBox_4"/>
</item>
<item>
<widget class="QListView" name="listView_2"/>
</item>
</layout>
</item>
</layout>
</widget>
@@ -102,7 +116,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<width>379</width>
<height>21</height>
</rect>
</property>
@@ -117,7 +131,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="kcnrtl.qrc"/>
<include location="../resources/kcnrtl.qrc"/>
</resources>
<connections/>
</ui>

+ 43
- 15
kcnrtl/kcnrtl.py View File

@@ -52,17 +52,24 @@ class Main(QMainWindow):
self.ui.comboBox.setCurrentIndex(0)

self.ui.checkBox.setChecked(False)

self.dictionaries = [u"TLFi",
u"Académie 9e Ed.",
u"Académie 8e Ed.",
u"Académie 4e Ed.",
]
self.ui.comboBox_2.addItems(self.dictionaries)
self.clipboard = QApplication.clipboard()

self.ui.lineEdit.returnPressed.connect(self.updateUi)

self.ui.comboBox.activated.connect(self.changeCombo)
self.ui.comboBox.activated.connect(self.onComboChange)
self.ui.webView.settings().setUserStyleSheetUrl(
QUrl.fromLocalFile(":/lexi.css"))
QUrl.fromLocalFile(':/lexi.css'))

self.ui.listView.clicked.connect(self.rowClicked)
self.ui.listView.clicked.connect(self.onRowClicked)

self.clipboard.dataChanged.connect(self.autoGetFromClipboard)

@@ -82,18 +89,27 @@ class Main(QMainWindow):

except:
self.ui.lineEdit.setText("Veuillez entrer un mot")
# # TODO: Dynamically adjust dictionaries name to windows size
# def resizeEvent(self, event):
# if event.size().width() < 449:
# i = 0
# while i <= len(self.ui.comboBox_2):
# self.ui.comboBox_2.setItemText(i, self.dictionaries_short[i])
# print 'size', event.size().width()

# Copy selected item in list to the clipboard
def rowClicked(self, qmodelindex):
self.item = qmodelindex.data(Qt.DisplayRole).toString()
self.clipboard.setText(self.item)
def onRowClicked(self, qmodelindex):
item = qmodelindex.data(Qt.DisplayRole).toString()
self.clipboard.setText(item)

def autoGetFromClipboard(self):
if self.ui.checkBox.isChecked():
self.ui.lineEdit.setText(unicode(self.clipboard.text()))
self.updateUi()

def changeCombo(self):
def onComboChange(self):
self.getLexi(self.typed)
self.lexiContent()
@@ -116,10 +132,14 @@ class Main(QMainWindow):
return soup

def lexiContent(self):
tagy = soup.find_all('div', {'id': 'contentbox'})
tag = str(tagy[0])
tagkeep = soup.find_all('div', {'id': 'contentbox'})
if not self.ui.comboBox_2.currentIndex():
tagrm = soup.find_all('div', {'class': 'tlf_cvedette'})
if 1 <= self.ui.comboBox_2.currentIndex() <= 3:
tagrm = soup.find_all('span', {'class': 'tlf_cvedette'})
tag = str(tagkeep[0]).replace(str(tagrm[0]),'')
self.ui.webView.setHtml(tag.decode('utf8'))
return tagy
return tag

# Check if there is more than one definition
def lexiForm(self):
@@ -137,11 +157,19 @@ class Main(QMainWindow):
return tagform

def getHtml(self, text, form):
conn = httplib2.Http(".cache")
conn = httplib2.Http('.kcnrtl_cache')
numdef = self.ui.comboBox.currentIndex()
if form == "definition":
htmlSource = conn.request("http://www.cnrtl.fr/%s/%s//%s" %
if not self.ui.comboBox_2.currentIndex():
htmlSource = conn.request("http://www.cnrtl.fr/%s/%s//%s" %
(form, text, numdef), "GET")
if self.ui.comboBox_2.currentIndex() > 0:
acad = unicode(self.ui.comboBox_2.currentText())
acadnum = filter(lambda x: x.isdigit(), acad)
acadnumf = "academie" + str(acadnum)
htmlSource = conn.request("http://www.cnrtl.fr/%s/%s/%s//%s" %
(form, acadnumf, text, numdef), "GET")

else:
htmlSource = conn.request("http://www.cnrtl.fr/%s/%s" %
(form, text), "GET")
@@ -149,8 +177,8 @@ class Main(QMainWindow):
# Delete cache directory on close
def closeEvent(self, event):
shutil.rmtree('.cache')
print "closed"
shutil.rmtree('.kcnrtl_cache')

class ListModel(QAbstractListModel):
def __init__(self, datain, parent=None, *args):

+ 2
- 2
setup.py View File

@@ -7,7 +7,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(name='KCnrtl',
version='0.1b',
version='0.2b',
description='KDE graphical client for the CNRTL linguistic resources',
license = "GPLv3",
author="Bogdan Cordier",
@@ -15,7 +15,7 @@ setup(name='KCnrtl',
url="http://code.lm7.fr/p/kcnrtl/",
download_url="http://code.lm7.fr/p/kcnrtl/downloads/",
packages=['kcnrtl', 'kcnrtl.gui', 'kcnrtl.resources'],
requires=['httplib2', 'bs4'],
requires=['httplib2', 'beautifulsoup4'],
long_description=read('README'),
classifiers=[
"Development Status :: 4 - Beta",

Loading…
Cancel
Save