Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kadnan committed Jun 7, 2020
1 parent d0ad427 commit 5c98ea1
Show file tree
Hide file tree
Showing 5 changed files with 716 additions and 0 deletions.
62 changes: 62 additions & 0 deletions example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package main

import (
"fmt"
"os"
"strconv"

"github.com/kadnan/fehrist/fehrist"
)

func main() {
path, _ := os.Getwd()

//Indexing CSV Files
CSVDocument := &fehrist.CSV{IndexName: "local"}
for i := 1; i < 3; i++ {
fileName := path + "/" + strconv.Itoa(i) + ".csv"
fmt.Println("Indexing CSV data from the file,", fileName, ". Please wait...")

indexCount, err := CSVDocument.Index(fileName)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Total Words indexed", indexCount)
}
}

//Indexing JSON files
JSONDocument := &fehrist.JSON{IndexName: "local"}
for i := 1; i < 3; i++ {
fileName := path + "/" + strconv.Itoa(i) + ".json"
fmt.Println("Indexing CSV data from the file,", fileName, ". Please wait...")

indexCount, err := JSONDocument.Index(fileName)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Total Words indexed", indexCount)
}
}

/* Searching Documents */

CSVDocument.Init()
result, _, err := CSVDocument.Search("siddiqi")
if err != nil {
fmt.Println(err)
}
fmt.Println("Printing the text present in CSV Document")
fmt.Println(result)

JSONDocument.Init()
result, searchCount, err := JSONDocument.Search("mango")
fmt.Println(searchCount)

if err != nil {
fmt.Println(err)
}
fmt.Println("Printing the text present in JSON Document")
fmt.Println(result)

}
Loading

0 comments on commit 5c98ea1

Please sign in to comment.