New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl code #20

Merged
merged 26 commits into from Mar 7, 2018

Conversation

Projects
None yet
2 participants
@melmothx
Contributor

melmothx commented Feb 28, 2018

This is a work in progress which is unclear if it will be ever completed... but given that it doesn't touch anything existing and just adds some sample code, you could take it as-is.

melmothx added some commits Feb 28, 2018

@ojwb

This comment has been minimized.

Contributor

ojwb commented Mar 2, 2018

We're certainly happy for partial work towards translating the example code.

However your changes break the build, which is problematic - try running:

make clean && make html LANGUAGE=perl

In the process of building the documentation this runs the new example code and verifies that the output matches the output the manual claims is produced, and also extracts snippets from the example code to insert into the generated documentation based on special comments in the the example code. These currently fail with your changes in several cases. For example:

  • the output format of code/perl/search_facets.pl adds the maker name which isn't present in the other versions

  • code/perl/search_ranges.pl dies with:

Xapian::Search::NumberRangeProcessor is not bound in perl! at code/perl/search_ranges.pl line 33.
  • code/perl/index_filters.pl is missing the ### End of new indexing code. special comment which tells the Sphinx xapianexample macro where to stop extracting example code to insert into the documentation.

melmothx added some commits Mar 2, 2018

Remove search_ranges.pl
It can't be done because of missing class and breaks the build as it is
@melmothx

This comment has been minimized.

Contributor

melmothx commented Mar 2, 2018

It should be good to go now.

rm -rf _build/*
rm -rf db statesdb
rm -rf code/c++/built
rm -f code/python/*.pyc code/python3/*.pyc
sphinx-build -b html -q -d _build/doctrees   -tperl . _build/html
/home/melmoth/amw/xapian/xapian-docsprint/concepts/search/search_limitations.rst:46: WARNING: unknown document: /advanced/remote
/home/melmoth/amw/xapian/xapian-docsprint/index.rst:14: WARNING: toctree contains reference to document u'language_specific' that doesn't have a title: no link will be generated
*** No version of example postingsource in language perl - patches welcome!
*** No version of example search_ranges in language perl - patches welcome!
*** No version of example index_ranges2 in language perl - patches welcome!
*** No version of example search_ranges2 in language perl - patches welcome!
*** No version of example search_sorting in language perl - patches welcome!
*** No version of example search_sorting2 in language perl - patches welcome!
*** No version of example index_values_with_geo in language perl - patches welcome!
*** No version of example search_sorting3 in language perl - patches welcome!
*** No version of example search_synonyms in language perl - patches welcome!

Build finished. The HTML pages are in _build/html.
@melmothx

This comment has been minimized.

Contributor

melmothx commented Mar 2, 2018

I think you can expect from me to complete the translation in a reasonable time, so please don't merge and let it open. Of course the ranges one can't be done because currently there is no perl binding for that. I'd also add some language specific note about encoding/decoding.

That's, at least, the grand plan.

melmothx added some commits Mar 4, 2018

Port search_ranges to perl
Use the methods an classes found on CPAN/debian
Add indexer and searcher for ranges2
Currently the build breaks because the subclass is missing
Add the processor class (no code)
First, it's not working and dies with this message:

Search::Xapian::QueryParser::add_valuerangeprocessor() -- vrproc is not a blessed SV reference at code/perl/search_ranges2.pl line 53

Second, it's not clear which method it should provide, or what this
class should be.
@melmothx

This comment has been minimized.

Contributor

melmothx commented Mar 6, 2018

I think that's it for now:

*** No version of example postingsource in language perl - patches welcome!
*** No version of example search_ranges in language perl - patches welcome!
*** No version of example search_ranges2 in language perl - patches welcome!
*** No version of example index_values_with_geo in language perl - patches welcome!
*** No version of example search_sorting3 in language perl - patches welcome!

These are scripts which can't currently work with Search::Xapian because of subclassing or because the class is missing.

@ojwb

Great. This mostly looks good, but I spotted a few minor nits:

# Index the MATERIALS field, splitting on semicolons.
foreach my $material (split(/;/, $rec->{MATERIALS})) {
$material =~ s/\A\s*//;
$material =~ s/\z\s*//;

This comment has been minimized.

@ojwb

ojwb Mar 6, 2018

Contributor

This removes whitespace after the end of the string - I think you meant s/\s*\z//.

my $material_query = Search::Xapian::Query->new(+OP_OR,
map { Search::Xapian::Query->new('XM' . lc($_)) }
@$materials);
$query = Search::Xapian::Query->new(+OP_FILTER, $query, $material_query);

This comment has been minimized.

@ojwb

ojwb Mar 6, 2018

Contributor

+ shouldn't be needed before the constants here.

my ($db_path, $query_string) = @ARGV;
die "Usage: $0 DB_PATH QUERYTERM..." unless $db_path && $query_string;

This comment has been minimized.

@ojwb

ojwb Mar 6, 2018

Contributor

This ignores any arguments after the second - the code in search_sorting.py looks better.

@ojwb

This comment has been minimized.

Contributor

ojwb commented Mar 6, 2018

Also this is a substantial contribution so you should probably update LICENSE.rst with copyright details.

@melmothx

This comment has been minimized.

Contributor

melmothx commented Mar 7, 2018

Please let me know if you want me to write some notes about perl specific encoding/decoding in the language specific section.

@ojwb

ojwb approved these changes Mar 7, 2018

@ojwb ojwb merged commit d3a42df into xapian:master Mar 7, 2018

@ojwb

This comment has been minimized.

Contributor

ojwb commented Mar 7, 2018

Please let me know if you want me to write some notes about perl specific encoding/decoding in the language specific section.

That sounds useful (in case you've not found it yet, adding some content language_specific/perl/index.rst should work).

@ojwb

This comment has been minimized.

Contributor

ojwb commented Mar 7, 2018

I've also pushed a changed to overview.rst to add Perl to the list of languages there's example code for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment