olament / hanzi2pinyinengine Goto Github PK
View Code? Open in Web Editor NEWHanzi to Pinyin engine in Swift 拼音输入法引擎
License: GNU General Public License v3.0
Hanzi to Pinyin engine in Swift 拼音输入法引擎
License: GNU General Public License v3.0
when input nihaoshijie
, the app crashed:
Pinyin2HanziEngine/SLMGraph.swift:121: Fatal error: Unexpectedly found nil while unwrapping an Optional value
https://github.com/Olament/Hanzi2PinyinEngine/blob/master/Pinyin2HanziEngine/Graphs/SLMGraph.swift#L121
var currentIndex = self.edgeTo[self.vertexCount - 1]!.from.id
This line thrown the exception.
I tried refactor the code to prevent the exception, but then I can't get any solution result.
Also tried to check out 01bee8a47
, it works, can get multiple senctences for the input nihaoshijie
, but the sort/order looks odd, not correct.
Can you help to give some hint for this?
Hi Olament, thanks for sharing the project.
I've cloned and checked that, but I found that the program only gave a result as the screenshot below.
The code in SMLGraph.swift also showed that It only gave a result as below.
// code in SLMGraph.swift , func of makSentence()
func makeSentence() -> Solution {
self.distanceTo[0] = 0 // set the starting vertex to zero
......
while currentIndex != 0 {
solution.pinyin = self.vertices[currentIndex].data!.pinyinSequence!.pinyinSequence + solution.pinyin
solution.sentence = self.vertices[currentIndex].data!.phrase! + solution.sentence
currentIndex = self.edgeTo[currentIndex]!.from.id
}
.......
return solution
}
So, I just wonder that is this the final version of your code? Would you mind to update your final version of code which can give the multiple results?
Thanks a lot!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.