Merge branch 'master' (with new upstream version 1.3.2) into debian

Conflicts:
	c2bscripts/c2bimport
	c2btools/c2bciter
	configure
parents 86cc179d 35741084
This diff is collapsed.
......@@ -9,12 +9,12 @@
# rusconi@mnhn.fr
#
# June 2009:
#
# - Make use of the "$@" argument instead of problematic "$1".
#
# See the LICENSE file that comes with this distribution
#
# Usage: c2bciter [BibTeX file or directory]
#-------------------------------------------------------------------------------
# Usage: c2bciter [dirname1 [dirname2 ... ]]
# c2bciter [filename1.bib [filename2.bib ... ]]
#-------------------------------------------------------------------------------
cb2bib --citer "$@"
......@@ -12,7 +12,7 @@
# - Make use of quoted "$1" argument instead of $1.
#
# See the LICENSE file that comes with this distribution
#
#-------------------------------------------------------------------------------
# Usage: c2bimport tmp_imported_reference_file
#-------------------------------------------------------------------------------
......
[Desktop Entry]
Comment=Donwload reference to cb2Bib
Comment[ca]=Exporta referències al cb2Bib
Comment[ca]=Importa referència al cb2Bib
Exec=cb2bib --import %f
GenericName=Reference Extracting Tool
GenericName[ca]=Eina per extreure referències
GenericName=cb2Bib Import Reference
GenericName[ca]=Importa referència al cb2Bib
Icon=cb2bib
MimeType=text/x-bibtex;application/x-download;application/bibtex;
Name=c2bImport
......
......@@ -15,9 +15,7 @@
# - Replace ' ' with ':' along with use of IFS=: as word-splitting
# delimiter for PATH-related tasks (Thanks Lionel Mamane).
#
# - Comment out code setting the absolute path to utilities on the
# basis of build-time detected binaries (Thanks Lionel Mamane).
#
#------------------------------------------------------------------------------
# ( originally based upon 'shell script to configure doxygen',
# http://www.stack.nl/~dimitri/doxygen/
# Copyright (C) 1997-2001 by Dimitri van Heesch )
......@@ -42,9 +40,6 @@ f_icondir=/usr/share/pixmaps
f_qmake=NO
f_make=NO
f_kfmclient=NO
f_pdftotext=NO
f_exiftool=NO
while test -n "$1"; do
case $1 in
......@@ -234,77 +229,6 @@ else
echo "not found"
fi
# - check for kfmclient -------------------------------------------------------
#echo -n "Checking for kfmclient... "
#if test "$f_kfmclient" = NO; then
# kfmclient_name="kfmclient"
# kfmclient_prog=NO
# IFS=:
# for j in $bin_dirs; do
# if test -x "$j/$kfmclient_name"; then
# if test -n "`$j/$kfmclient_name --version 2>/dev/null | grep KDE`"; then
# kfmclient_prog="$j/$kfmclient_name"
# break 1
# fi
# fi
# done
# unset IFS
# f_kfmclient="$kfmclient_prog"
#fi
#if test "$f_kfmclient" != NO; then
# echo "using $f_kfmclient"
#else
# echo "not found"
#fi
# - check for pdftotext -------------------------------------------------------
#echo -n "Checking for pdftotext... "
#if test "$f_pdftotext" = NO; then
# pdftotext_name="pdftotext"
# pdftotext_prog=NO
# IFS=:
# for j in $bin_dirs; do
# if test -x "$j/$pdftotext_name"; then
# pdftotext_prog="$j/$pdftotext_name"
# break 1
# fi
# done
# unset IFS
# f_pdftotext="$pdftotext_prog"
#fi
#
#if test "$f_pdftotext" != NO; then
# echo "using $f_pdftotext"
#else
# echo "not found"
#fi
# - check for exiftool -------------------------------------------------------
#echo -n "Checking for exiftool... "
#if test "$f_exiftool" = NO; then
# exiftool_name="exiftool"
# exiftool_prog=NO
# IFS=:
# for j in $bin_dirs; do
# if test -x "$j/$exiftool_name"; then
# exiftool_prog="$j/$exiftool_name"
# break 1
# fi
# done
# unset IFS
# f_exiftool="$exiftool_prog"
#fi
#if test "$f_exiftool" != NO; then
# echo "using $f_exiftool"
#else
# echo "not found"
#fi
#- Setting dirs and start qmake -----------------------------------------------
echo
......@@ -323,32 +247,7 @@ else
sed 's% disable_cbpoll%%g' src/src.pro > tmp.pro
mv -f tmp.pro src/src.pro
fi
sed 's%^const QString C2B_DATA_DIR .*$%const QString C2B_DATA_DIR = "'$f_datadir'/";%g' src/c2b/cb2bib_parameters.h > tmp.par
mv -f tmp.par src/c2b/cb2bib_parameters.h
if test "$f_kfmclient" != NO; then
sed 's%C2B_FM_CLIENT_COPY_BIN = "kfmclient".*$%C2B_FM_CLIENT_COPY_BIN = "'$f_kfmclient'";%g' src/c2b/cb2bib_parameters.h > tmp.par
else
sed 's%C2B_FM_CLIENT_COPY_BIN = "kfmclient".*$%C2B_FM_CLIENT_COPY_BIN = "kfmclient";%g' src/c2b/cb2bib_parameters.h > tmp.par
fi
mv -f tmp.par src/c2b/cb2bib_parameters.h
if test "$f_kfmclient" != NO; then
sed 's%C2B_FM_CLIENT_MOVE_BIN = "kfmclient".*$%C2B_FM_CLIENT_MOVE_BIN = "'$f_kfmclient'";%g' src/c2b/cb2bib_parameters.h > tmp.par
else
sed 's%C2B_FM_CLIENT_MOVE_BIN = "kfmclient".*$%C2B_FM_CLIENT_MOVE_BIN = "kfmclient";%g' src/c2b/cb2bib_parameters.h > tmp.par
fi
mv -f tmp.par src/c2b/cb2bib_parameters.h
if test "$f_pdftotext" != NO; then
sed 's%PDF2TXT_BIN = "pdftotext".*$%PDF2TXT_BIN = "'$f_pdftotext'";%g' src/c2b/cb2bib_parameters.h > tmp.par
else
sed 's%PDF2TXT_BIN = "pdftotext".*$%PDF2TXT_BIN = "pdftotext";%g' src/c2b/cb2bib_parameters.h > tmp.par
fi
mv -f tmp.par src/c2b/cb2bib_parameters.h
if test "$f_exiftool" != NO; then
sed 's%C2B_METADATAPARSER_EXIFTOOL_BIN = "exiftool".*$%C2B_METADATAPARSER_EXIFTOOL_BIN = "'$f_exiftool'";%g' src/c2b/cb2bib_parameters.h > tmp.par
else
sed 's%C2B_METADATAPARSER_EXIFTOOL_BIN = "exiftool".*$%C2B_METADATAPARSER_EXIFTOOL_BIN = "exiftool";%g' src/c2b/cb2bib_parameters.h > tmp.par
fi
sed 's%^const QString C2B_DATA_DIR.*$%const QString C2B_DATA_DIR("'$f_datadir'/");%g' src/c2b/cb2bib_parameters.h > tmp.par
mv -f tmp.par src/c2b/cb2bib_parameters.h
if test "$platform" = Darwin; then
......@@ -364,5 +263,13 @@ if test "$f_make" = NO; then
echo "Configuration ended. 'make' not found."
echo "Build toolchain might not be completed."
else
echo "-----------------------------------------------------------------------"
echo "Configuration ended. Type 'make' and 'make install'."
echo "-----------------------------------------------------------------------"
echo "- NOTE: 'make install' will copy the required runtime files to the"
echo " specified locations. Besides cb2bib binary, 'make install' will copy"
echo " the scripts c2bimport and c2bciter, and will set their executable"
echo " permissions. Also, it will set cb2bib, c2bimport, and c2bciter"
echo " desktop files."
echo "-----------------------------------------------------------------------"
fi
......@@ -42,13 +42,13 @@ ACR|Ann. Chim. (Rome)|Annali di Chimica
ACS|Acta Chem. Scand.|Acta Chemica Scandinavica
ACS|Acta Chim. Sinica|Acta Chimica Sinica
ACS|Adv. Chem. Ser.|Advances in Chemistry Series
ACSAFC|Acta Crystallogr., Sect. A: Found. Crystallogr.|Acta Crystallographica Section A: Foundations
ACAFC|Acta Crystallogr. A Found. Crystallogr.|Acta Crystallographica Section A: Foundations of Crystallography
ACSAMI|ACS Appl. Mater. Interfaces|ACS Applied Materials and Interfaces
ACSB|Am. Ceram. Soc. Bull.|American Ceramic Society Bulletin
ACSBSS|Acta Crystallogr., Sect. B: Struct. Sci|Acta Crystallographica Section B: Structural Science
ACSCCSC|Acta Crystallogr., Sect. C: Cryst. Struct. Commun.|Acta Crystallographica Section C: Crystal Structure Communications
ACSDBC|Acta Crystallogr., Sect D: Biol. Crystallogr.|Acta Crystallographica Section D: Biological Crystallography
ACSESRO|Acta Crystallogr. Sect. E: Struct. Rep. Online|Acta Crystallographica Section E Structure Reports Online
ACBSS|Acta Crystallogr. B|Acta Crystallographica Section B: Structural Science
ACCCSC|Acta Crystallogr. C Cryst. Struct. Commun.|Acta Crystallographica Section C: Crystal Structure Communications
ACDBC|Acta Crystallogr. D Biol. Crystallogr.|Acta Crystallographica Section D: Biological Crystallography
ACSESRO|Acta Crystallogr. Sect. E: Struct. Rep. Online|Acta Crystallographica Section E: Structure Reports Online
ACSM|Ann. Chim. - Sci. Mat.|Annales de Chimie - Science des Materiaux
ACSSS|ACS Symp. Ser.|ACS Symposium Series
ADNDT|At. Data Nucl. Data Tables|Atomic Data and Nuclear Data Tables
......@@ -313,6 +313,7 @@ COCB|Curr. Opin. Chem. Biol.|Current Opinion in Chemical Biology
COC|Curr. Org. Chem.|Current Organic Chemistry
COCIS|Curr. Opin. Colloid Interface Sci.|Current Opinion in Colloid and Interface Science
COP|Curr. Opin. Pharmacol.|Current Opinion in Pharmacology
COSB|Curr. Opin. Struct. Biol.|Current Opinion in Structural Biology
COSSMS|Curr. Opin. Solid State Mater. Sci.|Current Opinion in Solid State and Materials Science
CPA|Composites Part A|Composites Part A Applied Science and Manufacturing
CPB|Cell. Physiol. Biochem.|Cellular Physiology and Biochemistry
......@@ -1130,7 +1131,8 @@ PM|Prot. Met|Protection of Metals
PMR|Platinum Met. Rev.|Platinum Metals Review
PMSE|Polym. Mater. Sci. Eng.|Polymeric Materials Science and Engineering
PMS|Prog. Mater Sci.|Progress in Materials Science
PNAS|Proc. Natl. Acad. Sci. USA|Proceedings of the National Academy of Sciences of the United States of America
PNASUSA|Proc. Natl. Acad. Sci. USA|Proceedings of the National Academy of Sciences of the United States of America
PNAS|Proc. Natl. Acad. Sci. USA|Proceedings of the National Academy of Sciences
PNB|Polym. Networks Blends|Polymer Networks and Blends
PNMRS|Prog. Nucl. Magn. Reson. Spectrosc.|Progress in Nuclear Magnetic Resonance Spectroscopy
POC|Prog. Org. Coat.|Progress in Organic Coatings
......
......@@ -195,23 +195,11 @@ action=
journal=
query=http://www.ncbi.nlm.nih.gov/sites/entrez?orig_db=PubMed&db=PubMed&cmd=Search&term=<<doi>>[doi]
capture_from_query=\bPMID: (\d+)\D
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=Retrieve&db=pubmed&dopt=MEDLINE&list_uids=
referenceurl_sufix=
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/pubmed/
referenceurl_sufix=?report=xml&format=text
pdfurl_prefix=
pdfurl_sufix=
action=
# QUERY INFO FOR PubMed
# Exemple using HTML to text conversion
# Requests XML PubMed, use med2bib to convert
#journal=
#query=http://www.ncbi.nlm.nih.gov/sites/entrez?orig_db=PubMed&db=PubMed&cmd=Search&term=<<doi>>[doi]
#capture_from_query=\bPMID: (\d+)\D
#referenceurl_prefix=http://www.ncbi.nlm.nih.gov/pubmed/
#referenceurl_sufix=?report=xml&format=text
#pdfurl_prefix=
#pdfurl_sufix=
#action=htm2txt_referenceurl
action=htm2txt_referenceurl
# QUERY INFO FOR PROLA
# Extracts BibTeX reference
......@@ -241,11 +229,11 @@ journal=Proteins: Structure, Function, and Bioinformatics|Proteins
journal=Proteins: Structure, Function, and Genetics|Proteins
query=http://www.ncbi.nlm.nih.gov/sites/entrez?orig_db=PubMed&db=PubMed&cmd=Search&term=<<journal>>[Jour]+AND+<<volume>>[volume]+AND+<<pages>>[page]
capture_from_query=\bPMID: (\d+)\D
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=Retrieve&db=pubmed&dopt=MEDLINE&list_uids=
referenceurl_sufix=
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/pubmed/
referenceurl_sufix=?report=xml&format=text
pdfurl_prefix=
pdfurl_sufix=
action=
action=htm2txt_referenceurl
# QUERY INFO FOR PubMed
# Extracts Medline reference
......@@ -253,11 +241,11 @@ action=
journal=
query=http://www.ncbi.nlm.nih.gov/sites/entrez?orig_db=PubMed&db=PubMed&cmd=Search&term=<<journal>>[Jour]+AND+<<volume>>[volume]+AND+<<pages>>[page]
capture_from_query=\bPMID: (\d+)\D
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=Retrieve&db=pubmed&dopt=MEDLINE&list_uids=
referenceurl_sufix=
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/pubmed/
referenceurl_sufix=?report=xml&format=text
pdfurl_prefix=
pdfurl_sufix=
action=
action=htm2txt_referenceurl
# QUERY INFO FOR ACS
# BibTeX references are available... but they contain HTML encoding for non-ascii characters.
......@@ -364,11 +352,11 @@ action=browse_referenceurl
journal=
query=http://www.ncbi.nlm.nih.gov/sites/entrez?orig_db=PubMed&db=pubmed&cmd=Search&TransSchema=title&term=<<title>>
capture_from_query=\bPMID: (\d+)\D
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=Retrieve&db=pubmed&dopt=MEDLINE&list_uids=
referenceurl_sufix=
referenceurl_prefix=http://www.ncbi.nlm.nih.gov/pubmed/
referenceurl_sufix=?report=xml&format=text
pdfurl_prefix=
pdfurl_sufix=
action=
action=htm2txt_referenceurl
# QUERY INFO FOR Google Scholar
# Uses <<excerpt>> tag
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#include "bookmarkPlugin.h"
......@@ -29,7 +29,7 @@ bookmarkPlugin::~bookmarkPlugin()
void bookmarkPlugin::init()
{
QString nfn = c2bSettingsP->fileName("cb2Bib/NetworkFile");
const QString nfn(c2bSettingsP->fileName("cb2Bib/NetworkFile"));
if (nfn == _bookmark_file)
return;
if (QFileInfo(nfn).exists())
......@@ -45,8 +45,8 @@ void bookmarkPlugin::init()
void bookmarkPlugin::parseBookmarks()
{
clear();
const QString bmf = c2bUtils::fileToString(_bookmark_file);
QStringList bookmarks = bmf.split("\n", QString::KeepEmptyParts);
const QString bmf(c2bUtils::fileToString(_bookmark_file));
QStringList bookmarks(bmf.split('\n', QString::KeepEmptyParts));
const QRegExp _bookmark("^editorbookmark=");
const QRegExp _separator("^editorbookmark=\\s*$");
for (int i = 0; i < bookmarks.count(); ++i)
......@@ -59,7 +59,7 @@ void bookmarkPlugin::parseBookmarks()
if (bookmarks.at(i).contains(_bookmark))
{
bookmarks[i].remove(_bookmark);
QStringList bm_parts = bookmarks.at(i).split("|", QString::KeepEmptyParts);
const QStringList bm_parts(bookmarks.at(i).split('|', QString::KeepEmptyParts));
if (bm_parts.count() != 4)
{
qDebug(tr("[cb2bib] bookmarkPlugin::parseBookmarks: Syntax error at '%1'").arg(bookmarks.at(i)).toLatin1());
......@@ -100,7 +100,7 @@ void bookmarkPlugin::openBookmark()
QAction* act = static_cast<QAction*>(sender());
if (act)
{
QString fn = act->data().toString();
const QString fn(act->data().toString());
if (fn.endsWith(".bib")) // Open BiBTeX files internally
emit openFile(fn);
else
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#ifndef BOOKMARKPLUGIN_H
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#include "c2b.h"
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#ifndef C2B_H
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
*
* Class implementation of the approximate search algorithm
......@@ -47,12 +47,12 @@ void approximatePattern::setPattern()
}
// Set parameters
const double percentScan = 50.;
double scanFactor = 100. / percentScan;
int maxBlocks = patternPieces.count() / 2;
int requestedBlocks = c2bUtils::nearInteger(scanFactor);
int nBlocks = qMin(maxBlocks, 1 + requestedBlocks);
int nPiecesPerBlock = patternPieces.count() / nBlocks; // Ceiling
const double percentScan(50.);
const double scanFactor(100. / percentScan);
const int maxBlocks(patternPieces.count() / 2);
const int requestedBlocks(c2bUtils::nearInteger(scanFactor));
const int nBlocks(qMin(maxBlocks, 1 + requestedBlocks));
int nPiecesPerBlock(patternPieces.count() / nBlocks); // Ceiling
if ((patternPieces.count() % nBlocks) > 0)
nPiecesPerBlock++;
......@@ -63,7 +63,7 @@ void approximatePattern::setPattern()
// qDebug() << "block# " << b << "pick item " << b + (i*nBlocks) << patternPieces.at(b + (i*nBlocks));
QStringList subPatterns;
QString _stretch = ".{0,%1}%2";
const QString _stretch(".{0,%1}%2");
QRegExp _asrx;
_asrx.setPatternSyntax(QRegExp::RegExp2);
_asrx.setMinimal(false);
......@@ -72,15 +72,15 @@ void approximatePattern::setPattern()
for (int b = 0; b < nBlocks; ++b)
{
int ii = b;
QString sp = escape(patternPieces.at(ii), caseSensitivity);
int stretch_product = 1;
int ii(b);
QString sp(escape(patternPieces.at(ii), caseSensitivity));
int stretch_product(1);
for (int j = 1; j < nPiecesPerBlock; ++j)
{
int jj = b + (j * nBlocks);
int jj(b + (j * nBlocks));
if (jj < patternPieces.count())
{
int st = stretch(ii, jj);
const int st(stretch(ii, jj));
sp += _stretch.arg(st).arg(escape(patternPieces.at(jj), caseSensitivity));
stretch_product *= st;
ii = jj;
......@@ -107,15 +107,15 @@ void approximatePattern::splitPattern()
for (int i = 0; i < wordList.count(); ++i)
{
QStringList pieces = splitWord(wordList.at(i));
QString prefix = pieces.at(0);
const QStringList pieces(splitWord(wordList.at(i)));
const QString prefix(pieces.at(0));
if (prefix.length() > 2)
{
patternPieces.append(prefix);
ppStarts.append(wordStarts.at(i));
ppEnds.append(wordStarts.at(i) + prefix.length());
}
QString suffix = pieces.at(1);
const QString suffix(pieces.at(1));
if (suffix.length() > 2)
{
patternPieces.append(suffix);
......@@ -130,12 +130,12 @@ void approximatePattern::splitPattern(const QString& p, QStringList* w, QList<in
w->clear();
ws->clear();
we->clear();
QString str = p;
QString str(p);
str.replace(c2bUtils::nonLetter, " ");
str.append(' ');
int w_starts = 0;
int w_ends = 0;
bool in_word = false;
int w_starts(0);
int w_ends(0);
bool in_word(false);
for (int i = 0; i < str.length(); ++i)
if (str.at(i) == ' ')
{
......@@ -160,20 +160,20 @@ void approximatePattern::splitPattern(const QString& p, QStringList* w, QList<in
const QStringList approximatePattern::splitWord(const QString& word)
{
// Returns the pair "prefix+root root+suffix"
const int minimum_length = 5;
int wlen = word.length();
const int minimum_length(5);
const int wlen(word.length());
if (wlen < minimum_length)
return QStringList() << word << word;
QString w = word.toLower();
int plen_min = wlen;
int slen_min = wlen;
int plen_max = 0;
int slen_max = 0;
QString w(word.toLower());
int plen_min(wlen);
int slen_min(wlen);
int plen_max(0);
int slen_max(0);
for (int i = 0; i < pre.count(); ++i)
if (w.startsWith(pre.at(i)))
{
int plen = pre.at(i).length();
const int plen(pre.at(i).length());
if (plen < plen_min)
plen_min = plen;
if (plen > plen_max)
......@@ -182,7 +182,7 @@ const QStringList approximatePattern::splitWord(const QString& word)
for (int i = 0; i < suf.count(); ++i)
if (w.endsWith(suf.at(i)))
{
int slen = suf.at(i).length();
const int slen(suf.at(i).length());
if (slen < slen_min)
slen_min = slen;
if (slen > slen_max)
......@@ -194,10 +194,10 @@ const QStringList approximatePattern::splitWord(const QString& word)
slen_min = 0;
w = word;
int wlenMp_min = qMax(plen_min, wlen - slen_min);
int wlenMs_min = qMax(slen_min, wlen - plen_min);
int wlenMp_max = qMax(plen_max, wlen - slen_max);
int wlenMs_max = qMax(slen_max, wlen - plen_max);
const int wlenMp_min(qMax(plen_min, wlen - slen_min));
const int wlenMs_min(qMax(slen_min, wlen - plen_min));
const int wlenMp_max(qMax(plen_max, wlen - slen_max));
const int wlenMs_max(qMax(slen_max, wlen - plen_max));
// qDebug() << wlenMp_min << wlenMs_min << w.left(wlenMp_min) << w.right(wlenMs_min);
// qDebug() << wlenMp_max << wlenMs_max << w.left(wlenMp_max) << w.right(wlenMs_max);
......@@ -212,26 +212,26 @@ const QStringList approximatePattern::splitWord(const QString& word)
QString approximatePattern::wordPattern(const QString& word, Qt::CaseSensitivity cs) const
{
int len = word.length();
QString _ord = word.right(len - 1);
const int len(word.length());
const QString ord(word.right(len - 1));
QStringList possible;
possible.append(escape(_ord.left(len - 2), cs));
possible.append(escape(ord.left(len - 2), cs));
for (int i = 1; i < len - 2; ++i)
possible.append(QString("%1.{0,2}%2").arg(escape(_ord.left(len - i - 3), cs)).arg(escape(_ord.right(i), cs)));
//qDebug() << "WordPattern: " << QString("(?:%1(?:%2)|%3)").arg(escape(word.at(0), cs)).arg(possible.join("|")).arg(escape(_ord, cs));
return QString("(?:%1(?:%2)|%3)").arg(escape(word.at(0), cs)).arg(possible.join("|")).arg(escape(_ord, cs));
possible.append(QString("%1.{0,2}%2").arg(escape(ord.left(len - i - 3), cs)).arg(escape(ord.right(i), cs)));
//qDebug() << "WordPattern: " << QString("(?:%1(?:%2)|%3)").arg(escape(word.at(0), cs)).arg(possible.join("|")).arg(escape(ord, cs));
return QString("(?:%1(?:%2)|%3)").arg(escape(word.at(0), cs)).arg(possible.join("|")).arg(escape(ord, cs));
}
int approximatePattern::wordCount(const QString& str) const
{
const QString _str = QString(str).replace(c2bUtils::nonLetter, " ").simplified();
return 1 + _str.count(' ');
const QString tstr(QString(str).replace(c2bUtils::nonLetter, " ").simplified());
return 1 + tstr.count(' ');
}
int approximatePattern::stretch(int piece_i, int piece_j) const
{
const int minStretch = 3;
const int maxStretch = 20;
const int minStretch(3);
const int maxStretch(20);
if (patternPieces.at(piece_j).length() > 4)
return qMax((maxStretch*(piece_j - piece_i)), minStretch*(ppStarts.at(piece_j) - ppEnds.at(piece_i)));
else
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
*
* Class implementation of the approximate search algorithm
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#ifndef AUTHORSTRING_H
......@@ -17,17 +17,17 @@
namespace author
{
static const QString double_initials("(Al|Kh|Th|Ya|Yu|Zs)");
static const QString double_initials("(Al|Ch|Kh|Th|Ya|Yu|Zs)");
static const QString prefixes("(da|de|dal|del|der|di|do|du|dos|la|le|lo|van|vande|von|zur)");
static const QString name("(?:\\w[-'\\w]{1,})");
static const QString initials("(?:\\s*-{0,1}\\b\\w\\b\\.{0,1}){1,3}");
static const QString reversed_romance_name("(?:\\w[-'\\w]{1,})\\s+(?:\\w[-'\\w]{1,}),\\s*(?:\\w[-'\\w]{1,}|" + initials + ")");
static const QString reversed_romance_name("(?:\\w[-'\\w]{1,})\\s+(?:\\w[-'\\w]{1,}),\\s*(?:\\w[-'\\w]{1,}|" + initials + ')');
static const QRegExp reversed_name_rx("^" + name + ",");
static const QRegExp reversed_name_rx('^' + name + ',');
// Cases 'n1 n2, n3', 'n1 n2, n3 and n4 n5, n6', 'n1 n2, n3 and n4, n5 n6' are necessarily reverse order
static const QRegExp reversed_romance_name_rx("^(?:" + reversed_romance_name + "|"
+ reversed_romance_name + " and " + reversed_romance_name + "|"
static const QRegExp reversed_romance_name_rx("^(?:" + reversed_romance_name + '|'
+ reversed_romance_name + " and " + reversed_romance_name + '|'
+ reversed_romance_name + " and (?:\\w[-'\\w]{1,}),\\s*(?:\\w[-'\\w]{1,}|\\w[-'\\w]{1,} \\w[-'\\w]{1,}|" + initials + "))$");
// simplifyString
......@@ -93,8 +93,8 @@ struct encoder
void encode(const QString& raw);
void scape(const int pos, const int length, const QChar c = ' ')
{
const int pos0 = qMax(pos, 0);
const int posn = qMin(pos0 + length, code.length());
const int pos0(qMax(pos, 0));
const int posn(qMin(pos0 + length, code.length()));
for (int i = pos0; i < posn; ++i)
if (code.at(i) != 'L')
code[i] = c;
......@@ -106,7 +106,7 @@ struct encoder
rx.setPatternSyntax(QRegExp::RegExp2);
if (!rx.isValid())
exit(6);
int pos = 0;
int pos(0);
while (pos > -1)
{
pos = rx.indexIn(code, pos);
......
/***************************************************************************
* Copyright (C) 2004-2009 by Pere Constans
* constans@molspaces.com
* cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
* cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution.
***************************************************************************/
#include "bibExtractor.h"
......@@ -69,28 +69,28 @@ int bibExtractor::extract(const QStringList& input_fns, const QString& output_fn
if (_input_type == Document)
{
_document_fn = input_fn;
const QString text = documentToString(input_fn);
const QString text(documentToString(input_fn));
extract(text);
}
else
{
_document_fn.clear();
const QString text = c2bUtils::fileToString(input_fn);
const QString text(c2bUtils::fileToString(input_fn));
extract(text);
}
if (_settingsP->value("cb2Bib/MovePdf").toBool() && !_document_fn.isEmpty() && _bpP->fieldCount() > 0)
{
const QString file = _bpP->documentFilename(_document_fn, output_fn);
const QString target_doc_fn = c2bUtils::documentAbsoluteName(_settingsP->value("cb2Bib/RelativePdfDirectory").toBool(),
output_fn, _settingsP->fileName("cb2Bib/PdfDirectory"), file);
const QString doc_dirname = QFileInfo(target_doc_fn).absolutePath();
const QString file(_bpP->documentFilename(_document_fn, output_fn));
const QString target_doc_fn(c2bUtils::documentAbsoluteName(_settingsP->value("cb2Bib/RelativePdfDirectory").toBool(),
output_fn, _settingsP->fileName("cb2Bib/PdfDirectory"), file));
const QString doc_dirname(QFileInfo(target_doc_fn).absolutePath());
QDir doc_dir(doc_dirname);
if (!doc_dir.exists())
if (!doc_dir.mkpath(doc_dirname))
logMessage(tr("Unable to create directory %1.").arg(doc_dirname));
if (doc_dir.exists())
{
const QString CopyMovePdf = _settingsP->value("cb2Bib/CopyMovePdf").toString();
const QString CopyMovePdf(_settingsP->value("cb2