當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Quad.NQuad方法代碼示例

本文整理匯總了Golang中github.com/google/cayley/quad.Quad.NQuad方法的典型用法代碼示例。如果您正苦於以下問題:Golang Quad.NQuad方法的具體用法?Golang Quad.NQuad怎麽用?Golang Quad.NQuad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/cayley/quad.Quad的用法示例。


在下文中一共展示了Quad.NQuad方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	// Writer of link between entities and sentences.
	rdfWriter := gzip.NewWriter(os.Stdout)

	defer func() {
		rdfWriter.Flush()
		rdfWriter.Close()
	}()

	// Read ASSIGNMENT.csv
	r := csv.NewReader(os.Stdin)
	line := 0
	for {
		record, err := r.Read()
		line++
		if err == io.EOF {
			break
		} else if err != nil {
			fmt.Fprintf(os.Stderr, "Error line %d: %v\n", line, err)
			continue
		}

		if line%10000 == 0 {
			fmt.Fprintf(os.Stderr, "Line %d\n", line)
		}

		// Link to entity.
		quad := quad.Quad{
			Subject:   "<" + record[1] + ">",
			Predicate: "<http://rdf.romainstrock.com/ns/sentence.is_about>",
			Object:    "<" + record[3] + ">",
		}
		fmt.Fprintln(rdfWriter, quad.NQuad())
	}
}
開發者ID:srom,項目名稱:ensu,代碼行數:35,代碼來源:link_entities_sentences.go

示例2: main

func main() {
	// Writer of link between entities and sentences.
	rdfWriter := gzip.NewWriter(os.Stdout)

	defer func() {
		rdfWriter.Flush()
		rdfWriter.Close()
	}()

	// Read SENTENCES.csv
	r := csv.NewReader(os.Stdin)
	line := 0
	for {
		record, err := r.Read()
		line++
		if err == io.EOF {
			break
		} else if err != nil {
			fmt.Fprintf(os.Stderr, "Error line %d: %v\n", line, err)
			continue
		}

		if line%10000 == 0 {
			fmt.Fprintf(os.Stderr, "Line %d\n", line)
		}

		// Speaker.
		quad_1 := quad.Quad{
			Subject:   "<" + record[0] + ">",
			Predicate: "<http://rdf.romainstrock.com/ns/sentence.speaker>",
			Object:    "<" + record[3] + ">",
		}
		fmt.Fprintln(rdfWriter, quad_1.NQuad())

		// Sentence text.
		text := record[6]
		quad_2 := quad.Quad{
			Subject:   "<" + record[0] + ">",
			Predicate: "<http://rdf.romainstrock.com/ns/sentence.text>",
			Object:    strconv.Quote(text),
		}
		fmt.Fprintln(rdfWriter, quad_2.NQuad())

		// Source URL.
		quad_3 := quad.Quad{
			Subject:   "<" + record[0] + ">",
			Predicate: "<http://rdf.romainstrock.com/ns/sentence.source_url>",
			Object:    "<" + record[5] + ">",
		}
		fmt.Fprintln(rdfWriter, quad_3.NQuad())
	}
}
開發者ID:srom,項目名稱:ensu,代碼行數:52,代碼來源:sentence_to_text.go


注:本文中的github.com/google/cayley/quad.Quad.NQuad方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。