sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

search_doc does not find phrases across multiple lines #7313

Closed 6bdad4c1-1e26-4f2f-a442-a01a2292c181 closed 14 years ago

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 15 years ago

Hello !!!

Out of curiosity, I tried to look for a function I knew in Sage :

sage: search_doc("Floyd-Warshall")
html/en/reference/sage/graphs/graph.html:5797:<dd><p>Uses the Floyd-Warshall algorithm to find a shortest weighted path
sage: search_doc("Floyd-Warshall","pair")
sage: Graph.shortest_path_all_pairs?

I understand the current way to look for things in the doc is to grep it, and that for some reason we may need to keep our lines short ( less than 80 characters or so ).. I also understand that finding another way to search the doc ( if there is none available already ) may be some big amount of work. Even though, this really isn't the expected behaviour of the function, and I think we should do something about it.

Nathann

CC: @dandrake

Component: documentation

Author: John Palmieri

Reviewer: Ross Kyprianou, Mitesh Patel

Merged: sage-4.3.3.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/7313

mwhansen commented 15 years ago
comment:1

Please use summaries that actually describe the problem.

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 15 years ago
comment:2

Got it !! I mixed Sage-devel and TRAC :-) Sorry !

jhpalmieri commented 14 years ago

Author: John Palmieri

jhpalmieri commented 14 years ago
comment:3

Here's a patch implementing a "multiline" keyword for searches, so you can do

sage: print search_src('dhsw', 'betti', interact=False)

sage: print search_src('dhsw', 'betti', interact=False, multiline=True)
homology/chain_complex.py
homology/simplicial_complex.py

(With multiline searches, it doesn't return line numbers, just the file names.)

jhpalmieri commented 14 years ago

Attachment: trac_7313-multiline.patch.gz

depends on #7018

f5e5bb2a-136b-4586-934a-bb3bfecf7daa commented 14 years ago
comment:4

Tested this on sage-4.3.2.alpha0 with trac_7313-multiline.patch (tried the patch in ticket #7018 but that had errors)

Look for occurrences of "Pseudo". We find two occurrences.

sage: search_src("Pseudo-")
combinat/words/word.py:2655:        -   [2] V. Anne, L.Q. Zamboni, I. Zorca, Palindromes and Pseudo-
combinat/words/word.py:2656:            Palindromes in Episturmian and Pseudo-Palindromic Infinite Words,
rings/all.py:122:# Pseudo-ring of PARI objects.
databases/compressed_storage.py:113:        Pseudo-acquisition for base's stuff that we don't

Next, search for a multiline ocurrence of "Pseudo-Palindromes" which should occur over lines 2655-2656 in word.py according to the last search. (Note: the 2nd line is prefixed with whitespace)

sage: search_src("Pseudo-Palindromes", multiline=True) # finds nothing

Not sure if the problem is due to the patch mentioned in #7018 needs including and updating for alpha0, or this ticket needs more work or theres something Ive missed.

jhpalmieri commented 14 years ago
comment:5

Tested this on sage-4.3.2.alpha0 with trac_7313-multiline.patch (tried the patch in ticket #7018 but that had errors)

(The patch from #7018 is already part of 4.3.2.alpha0, which is probably why applying it gave you errors.)

Since the string "Pseudo-Palindromes" doesn't appear, I think it is correct that searching for it returns nothing. Try this instead:

sage: search_src("Pseudo-", "Palindromes", multiline=True)

Actually, though, Pseudo- and Palindromes appear on the same line, so this isn't the best test case. How about

sage: search_src("Zamboni", "Infinite")

sage: search_src("Zamboni", "Infinite", multiline=True)
combinat/words/word.py
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Reviewer: Mitesh Patel

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:6

Quick note: multiline = kwds.get('multiline', False), etc., should also work.

f5e5bb2a-136b-4586-934a-bb3bfecf7daa commented 14 years ago
comment:7

(Confirming positive review). Tried a number of tests, verified using egrep and all worked (including using options such as path_re and ignore_case). Representative test below.

sage: search_src("Labbe",path_re=".*py") # returned a few occurences including in word.py (not shown)

sage: search_src("Pirillo",path_re=".*py") 
combinat/words/word_generators.py:753:        -   [1] X. Droubay, J. Justin, G. Pirillo, Episturmian words and some
combinat/words/word_generators.py:756:        -   [2] J. Justin, G. Pirillo, Episturmian words and episturmian
combinat/words/word.py:2875:        -   [3] X. Droubay, J. Justin, G. Pirillo, Episturmian words and

sage: search_src("Pirillo","Labbe",path_re=".*py") # not found (on same line)

sage: search_src("Pirillo","Labbe",multiline=True,path_re=".*py") # Expect one occurence and found one.
combinat/words/word_generators.py
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Merged: sage-4.3.3.alpha0

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Changed reviewer from Mitesh Patel to Ross Kyprianou, Mitesh Patel