// Determine whether the sentiment of text is positive // Use a web service async function isPositive(text: string): Promise {
const response = await fetch(`http://text-processing.com/api/sentiment/`, {
method: "POST",
body: `text=${text}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
const json = await response.json();
return json.label === "pos"; }
-- package main
type Run struct {
Time int // in milliseconds
Results string
Failed bool }
// Get average runtime of successful runs in seconds func averageRuntimeInSeconds(runs []Run) float64 {
var totalTime int
var failedRuns int
for _, run := range runs {
if run.Failed {
failedRuns++
} else {
totalTime += run.Time
}
}
コード生成ねぇ……🤔 (スコア:-1)
どーせ、できるのはgetter, setterの生成レベルくらいなんでしょ?
「nullの時は代わりに”hogehoge”を返す」くらいのことはコメントに書いておけば生成できるかもしれんが。
あとは、いろんなプロジェクトで同じ関数名、同じ引数、同じ処理内容でコピペされまくって頻出の慣用句みたいになってる処理とか。
「平易な英語で」表現されるレベルのコードなら、逆説的にコードに軽く目を通せば何やってるかわかるから説明コメントを書く必要がないし。(仕様書としてのコメントが必須な場合を除く)
Re:コード生成ねぇ……🤔 (スコア:-1)
#!/usr/bin/env ts-node
import { fetch } from "fetch-h2";
// Determine whether the sentiment of text is positive
// Use a web service
async function isPositive(text: string): Promise {
const response = await fetch(`http://text-processing.com/api/sentiment/`, {
method: "POST",
body: `text=${text}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
const json = await response.json();
return json.label === "pos";
}
--
package main
type Run struct {
Time int // in milliseconds
Results string
Failed bool
}
// Get average runtime of successful runs in seconds
func averageRuntimeInSeconds(runs []Run) float64 {
var totalTime int
var failedRuns int
for _, run := range runs {
if run.Failed {
failedRuns++
} else {
totalTime += run.Time
}
}
averageRuntime := float64(totalTime) / float64(len(runs) - failedRuns) / 1000
return averageRuntime
}
--
/**
* json schema:
* [
* { name: "John Doe",
* collaborators: ["Jane Doe", "Herbert Frapp", "Elsie McEwan"]
* },
* { name: "Jane Doe",
* collaborators: ["John Doe", "Karen Smith"]
* },
* { name: "Skittles the Cat",
* collaborators: []
* }
* ]
*/
function collaborators_map(json: any): Map> {
const map = new Map>();
for (const item of json) {
const name = item.name;
const collaborators = item.collaborators;
const set = new Set(collaborators);
map.set(name, set);
}
return map;
}
--
interface CommentMarker {
start: string;
end: string;
}
const markers: { [language:string]: CommentMarker } = {
javascript: { start: '//', end: ''},
python: { start: '#', end: ''},
css: { start: '/*', end: '*/'},
html: { start: ''},
bash: { start: '#', end: ''},
postscript: { start: '%', end: ''},
cobol: { start: '*', end: ''}
asm: { start: ';', end: ''},
haskell: { start: '--', end: ''}
}
--
def strip_suffix(filename):
"""
Removes the suffix from a filename
"""
return filename[:filename.rfind('.')]
def test_strip_suffix():
"""
Tests for the strip_suffix function
"""
assert strip_suffix('notes.txt') == 'notes'
assert strip_suffix('notes.txt.gz') == 'notes.txt'
太字部分がcopilotの生成です。プロジェクトのトップページからコピペしました。
どーせ、できるのはgetter, setterの生成レベルくらいなんでしょ?
なんというか、IT技術者って素人以下なんですね。
Re: (スコア:0)
こういうのがまさに、あらかじめ用意された慣用句的コードじゃねえなの?
まあ数行のコメントでそれ以上のコードを生成するには用意されたテンプレを使うことになるわな
Re: (スコア:0)
どーせ、できるのはgetter, setterの生成レベルくらいなんでしょ?
なんというか、IT技術者って素人以下なんですね。
元の発言者を根拠もなくIT技術者と見做す、ChaldeaGeckoの頭が心配だわ。
って自称アスペだっけ。
#悪意を持った書き込みには、悪意を贈るぜ