Changed name extraction
svn: r331
This commit is contained in:
parent
0453816f87
commit
e3f7028adc
@ -759,12 +759,25 @@ def new_database_response(val):
|
||||
def marriage_edit(family):
|
||||
Marriage.Marriage(family,database)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def tool_callback(val):
|
||||
if val:
|
||||
full_update()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def full_update():
|
||||
global id2col
|
||||
|
||||
id2col = {}
|
||||
person_list.clear()
|
||||
gtop.get_widget(NOTEBOOK).set_show_tabs(Config.usetabs)
|
||||
clist = gtop.get_widget("child_list")
|
||||
clist.set_column_visibility(4,Config.show_detail)
|
||||
@ -898,7 +911,7 @@ def update_source_after_edit(source):
|
||||
#-------------------------------------------------------------------------
|
||||
def on_tools_clicked(obj):
|
||||
if active_person:
|
||||
Plugins.ToolPlugins(database,active_person,update_display)
|
||||
Plugins.ToolPlugins(database,active_person,tool_callback)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -2333,16 +2346,6 @@ def apply_filter():
|
||||
global id2col
|
||||
global alt2col
|
||||
|
||||
people = database.getPersonMap().values()
|
||||
|
||||
names = []
|
||||
altnames = []
|
||||
for person in people:
|
||||
names.append((person.getPrimaryName(),person,0))
|
||||
if Config.hide_altnames == 0:
|
||||
for name in person.getAlternateNames():
|
||||
names.append((name,person,1))
|
||||
|
||||
person_list.freeze()
|
||||
|
||||
datacomp = DataFilter.compare
|
||||
@ -2378,6 +2381,9 @@ def apply_filter():
|
||||
sort.build_sort_name(name),sort_bday,sort_dday])
|
||||
person_list.set_row_data(0,pos)
|
||||
|
||||
if Config.hide_altnames:
|
||||
continue
|
||||
|
||||
for name in person.getAlternateNames():
|
||||
pos = (person,1)
|
||||
new_alt2col[person].append(pos)
|
||||
|
@ -23,13 +23,20 @@
|
||||
import os
|
||||
import re
|
||||
import intl
|
||||
import utils
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
from gnome.ui import *
|
||||
|
||||
import libglade
|
||||
import RelLib
|
||||
import utils
|
||||
|
||||
title_list = []
|
||||
nick_list = []
|
||||
cb = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Search each name in the database, and compare the firstname against the
|
||||
@ -39,46 +46,72 @@ import utils
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback):
|
||||
|
||||
global cb
|
||||
|
||||
cb = callback
|
||||
title_re = re.compile(r"^([A-Za-z][A-Za-z]+\.)\s+(.*)$")
|
||||
nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
|
||||
title_count = 0
|
||||
nick_count = 0
|
||||
|
||||
personMap = database.getPersonMap()
|
||||
for key in personMap.keys():
|
||||
|
||||
person = personMap[key]
|
||||
name = person.getPrimaryName()
|
||||
first = name.getFirstName()
|
||||
first = person.getPrimaryName().getFirstName()
|
||||
match = title_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
name.setFirstName(groups[1])
|
||||
name.setTitle(groups[0])
|
||||
title_count = title_count + 1
|
||||
title_list.append((person,groups[0],groups[1]))
|
||||
|
||||
match = nick_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
name.setFirstName(groups[0])
|
||||
person.setNickName(groups[1])
|
||||
nick_count = nick_count + 1
|
||||
nick_list.append((person,groups[0],groups[1]))
|
||||
|
||||
if nick_count == 1:
|
||||
msg = _("1 nickname was extracted")
|
||||
msg = ""
|
||||
if len(nick_list) > 0 or len(title_list) > 0:
|
||||
if len(nick_list) > 0:
|
||||
for name in nick_list:
|
||||
msg = msg + _("%s will be extracted as a nickname from %s\n") % \
|
||||
(name[2],name[0].getPrimaryName().getName())
|
||||
|
||||
if len(title_list) > 0:
|
||||
for name in title_list:
|
||||
msg = msg + _("%s will be extracted as a title from %s\n") % \
|
||||
(name[0].getPrimaryName().getName(),name[1])
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "patchnames.glade"
|
||||
|
||||
top = libglade.GladeXML(glade_file,"summary")
|
||||
top.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_ok_clicked" : on_ok_clicked
|
||||
})
|
||||
top.get_widget("textwindow").show_string(msg)
|
||||
else:
|
||||
msg = _("%d nicknames were extracted\n") % nick_count
|
||||
GnomeOkDialog(_("No titles or nicknames were found"))
|
||||
callback(0)
|
||||
|
||||
if title_count == 1:
|
||||
msg = msg + "\n" + _("1 title was extracted")
|
||||
else:
|
||||
msg = msg + "\n" + _("%d titles were extracted") % title_count
|
||||
|
||||
if nick_count > 0 or title_count > 0:
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_ok_clicked(obj):
|
||||
for grp in nick_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[1])
|
||||
grp[0].setNickName(grp[2])
|
||||
utils.modified()
|
||||
|
||||
box = GnomeOkDialog(msg)
|
||||
box.show()
|
||||
callback(1)
|
||||
for grp in title_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[2])
|
||||
name.setTitle(grp[1])
|
||||
utils.modified()
|
||||
|
||||
utils.destroy_passed_object(obj)
|
||||
cb(1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -88,6 +121,11 @@ def runTool(database,active_person,callback):
|
||||
def get_description():
|
||||
return _("Searches the entire database and attempts to extract titles and nicknames that may be embedded in a person's given name field.")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_name():
|
||||
return _("Database Processing/Extract information from names")
|
||||
|
||||
|
170
gramps/src/plugins/patchnames.glade
Normal file
170
gramps/src/plugins/patchnames.glade
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0"?>
|
||||
<GTK-Interface>
|
||||
|
||||
<project>
|
||||
<name>summary</name>
|
||||
<program_name>summary</program_name>
|
||||
<directory></directory>
|
||||
<source_directory>src</source_directory>
|
||||
<pixmaps_directory>pixmaps</pixmaps_directory>
|
||||
<language>C</language>
|
||||
<gnome_support>True</gnome_support>
|
||||
<gettext_support>True</gettext_support>
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GtkDialog</class>
|
||||
<name>summary</name>
|
||||
<title>Gramps - Name and Title Extraction Tool</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>Dialog:vbox</child_name>
|
||||
<name>dialog-vbox1</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<child_name>Dialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<border_width>10</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>5</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox1</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button3</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_ok_clicked</handler>
|
||||
<object>summary</object>
|
||||
<last_modification_time>Sun, 12 Aug 2001 17:26:36 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_YES</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button4</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>destroy_passed_object</handler>
|
||||
<object>summary</object>
|
||||
<last_modification_time>Sun, 12 Aug 2001 17:26:57 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_NO</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox1</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>summaryTitle</name>
|
||||
<width>500</width>
|
||||
<height>16</height>
|
||||
<label>Name and Title Extraction Tool</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>8</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHSeparator</class>
|
||||
<name>hseparator1</name>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label1</name>
|
||||
<label>Below is a list of the nicknames and titles that Gramps can extract from the
|
||||
current database. If you select "Yes", Gramps will modify your database as
|
||||
specified below. If you do not approve of these changes, you should select
|
||||
"No", and your database will not be altered.
|
||||
|
||||
Should the following changes be made?</label>
|
||||
<justify>GTK_JUSTIFY_LEFT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>10</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeLess</class>
|
||||
<name>textwindow</name>
|
||||
<height>250</height>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
</GTK-Interface>
|
Loading…
Reference in New Issue
Block a user