Skip to content

Commit

Permalink
#25 変数名の調整
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed Apr 28, 2024
1 parent 98f50b4 commit 078c5f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions KoeBook.Core/Services/ClaudeAnalyzerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async ValueTask<BookScripts> LlmAnalyzeScriptLinesAsync(BookProperties bo
},
cancellationToken: cancellationToken
);
(var characterList, var characterIdNameDic) = ExtractCharacterList(message1.ToString(), scriptLines);
(var characterList, var characterIdNameDictionary) = ExtractCharacterList(message1.ToString(), scriptLines);
progress.IncrementProgress();

var message2 = await _claudeService.Messages.CreateAsync(new()
Expand All @@ -50,7 +50,7 @@ public async ValueTask<BookScripts> LlmAnalyzeScriptLinesAsync(BookProperties bo
},
cancellationToken: cancellationToken
);
var characterVoiceMapping = ExtractCharacterVoiceMapping(message2.ToString(), characterIdNameDic);
var characterVoiceMapping = ExtractCharacterVoiceMapping(message2.ToString(), characterIdNameDictionary);
progress.Finish();

return new(bookProperties, new(characterVoiceMapping)) { ScriptLines = scriptLines };
Expand Down Expand Up @@ -180,20 +180,20 @@ private static (List<Character>, Dictionary<string, string>) ExtractCharacterLis
}
}

var dic = characterList.Select(x => KeyValuePair.Create(x.Id, x.Name)).ToDictionary();
var lines2 = lines.AsSpan()[(characterListEndIndex + 1)..];
var characterIdNameDictionary = characterList.Select(x => (x.Id, x.Name)).ToDictionary();
var voiceIdLines = lines.AsSpan()[(characterListEndIndex + 1)..];

for (var i = 0; i < lines2.Length; i++)
for (var i = 0; i < voiceIdLines.Length; i++)
{
var line = lines2[i].AsSpan();
var line = voiceIdLines[i].AsSpan();
line = line[(line.IndexOf(' ') + 2)..];//cまで無視
line = line[..line.IndexOf(' ')];// 二人以上話す時には先頭のものを使う
if (dic.TryGetValue(line.ToString(), out var characterName))
if (characterIdNameDictionary.TryGetValue(line.ToString(), out var characterName))
{
scriptLines[i].Character = characterName;
}
}
return (characterList, dic);
return (characterList, characterIdNameDictionary);
}

private class Character
Expand Down

0 comments on commit 078c5f5

Please sign in to comment.