database: match full import paths, don't split on periods.

For all projects we now index the full import path. So user can search
for example gddo/doc.

Handle urls and float numbers as one term, such as v.io, 0.8.

This fixes #366, and fixes #384.

Change-Id: Ia2c95ddcb64963590edc19d5fb4d4b06ea19e018
Reviewed-on: https://go-review.googlesource.com/20563
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/database/index.go b/database/index.go
index 69279bb..05f5864 100644
--- a/database/index.go
+++ b/database/index.go
@@ -21,7 +21,7 @@
 }
 
 func isTermSep(r rune) bool {
-	return unicode.IsSpace(r) || unicode.IsPunct(r) || unicode.IsSymbol(r)
+	return unicode.IsSpace(r) || unicode.IsPunct(r) && r != '.' || unicode.IsSymbol(r)
 }
 
 func normalizeProjectRoot(projectRoot string) string {
@@ -43,7 +43,9 @@
 	if x, ok := synonyms[s]; ok {
 		s = x
 	}
-	return stem(s)
+
+	// Trim the trailing period at the end of any sentence.
+	return stem(strings.Trim(s, "."))
 }
 
 var httpPat = regexp.MustCompile(`https?://\S+`)
@@ -125,11 +127,10 @@
 
 	if score > 0 {
 
-		if isStandardPackage(pdoc.ImportPath) {
-			for _, term := range parseQuery(pdoc.ImportPath) {
-				terms[term] = true
-			}
-		} else {
+		for _, term := range parseQuery(pdoc.ImportPath) {
+			terms[term] = true
+		}
+		if !isStandardPackage(pdoc.ImportPath) {
 			terms["all:"] = true
 			for _, term := range parseQuery(pdoc.ProjectName) {
 				terms[term] = true
diff --git a/database/index_test.go b/database/index_test.go
index e0092bf..655b4b3 100644
--- a/database/index_test.go
+++ b/database/index_test.go
@@ -77,13 +77,13 @@
 	},
 		[]string{
 			"all:",
-			"5849", "cly", "defin", "dir", "go",
+			"5849", "cly", "defin", "dir", "github.com", "go",
 			"import:bytes", "import:crypto/hmac", "import:crypto/sha1",
 			"import:encoding/base64", "import:encoding/binary", "import:errors",
 			"import:fmt", "import:io", "import:io/ioutil", "import:net/http",
 			"import:net/url", "import:regexp", "import:sort", "import:strconv",
 			"import:strings", "import:sync", "import:time", "interfac",
-			"oau", "project:github.com/user/repo", "rfc", "subset",
+			"oau", "project:github.com/user/repo", "repo", "rfc", "subset", "us",
 		},
 	},
 }