本文整理匯總了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())
}
}
示例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())
}
}