Morph21 / MercuryTrade-Community-Fork

An overlay application for Path of Exile(Tracking, Trading, Chat, etc)
MIT License
136 stars 24 forks source link

[FEATURE REQUEST] - Detecting other languages #50

Open Sparh4wk opened 3 years ago

Sparh4wk commented 3 years ago

Hi,

is it possible to add support for detecting other language like Russian, Chinese etc when using whisper feature on pathofexile trade website?

so msges like this one:

@Трейнгар Здравствуйте, хочу купить у вас Табула раса Матерчатая безрукавка за 6 chaos в лиге Ритуал (секция "Trade"; позиция: 3 столбец, 2 ряд)

or this one:

@캐릭명좆같네 안녕하세요, 의식(보관함 탭 "거래", 위치: 왼쪽 11, 상단 1)에 6 chaos(으)로 올려놓은 타뷸라 라사(Tabula Rasa) 단순한 로브(을)를 구매하고 싶습니다

are properly detected as trade messages and pasted into game?

thanks!

btw good job on this "addon"

Morph21 commented 3 years ago

It's possible but i don't have a template in these languages. And google translate dont work perfect with russian and korean

Sparh4wk commented 3 years ago

well its always starting with 안녕하세요 and Здравствуйте which means Hi/Hello. so why not just detecting those?

Morph21 commented 3 years ago

The issue is not only about starting letters, it needs to be sliced into groups. For example when slicing english message you need something like this:

"^(.\s)?(.+): (.+ to buy your\s+?(.+?)(\s+?listed for\s+?([\d\.]+?)\s+?(.+))?\s+?in\s+?(.+?)\s+?\(stash tab \"(.)\"; position: left (\d+), top (\d+)\)\s?(.))$"

Morph21 commented 3 years ago

I did started some work on it few weeks ago and made this:

^(.\s)?(.+): (안녕하세요, (.+?)\s(보관함 탭 "(.)", 위치: 왼쪽 (\d+), 상단 (\d+))에\s+?([\d.])\s(.)\s(으)로 올려놓은\s(.)을(를) 구매하고 싶습니다\s(.*))$

but it's not working properly yet :/

It's just a lot of work with translations etc.

queicherius commented 3 years ago

In case it helps, here's some more language samples:

Hi, I would like to buy your The Putrid Cloister Museum Map (T11) listed for 10 chaos in Ritual (stash tab "~price 10 chaos"; position: left 5, top 6)
Hi, ich möchte 'Das faulige Kloster 'Museum'-Karte (Lvl. 11)' zum angebotenen Preis von 10 chaos in der Ritual-Liga kaufen (Truhenfach "sell"; Position: 7 von links, 12 von oben)
Здравствуйте, хочу купить у вас Тлетворная обитель Карта музея (T11) за 10 chaos в лиге Ритуал (секция "trade"; позиция: 1 столбец, 1 ряд)
안녕하세요, 의식(보관함 탭 "판매", 위치: 왼쪽 7, 상단 12)에 10 chaos(으)로 올려놓은 악취 나는 수도원(The Putrid Cloister) 박물관 지도(Museum Map)(T11)(을)를 구매하고 싶습니다
Sparh4wk commented 3 years ago

hopefully you can do this, cause right now its like 70%+ trades are not from english ppl :( but otherwise its the best one!

Morph21 commented 3 years ago

@queicherius That will be extremely helpful. Thank you for your contribution

8Times commented 3 years ago

@Morph21 Hi there! I might help you tremendously!

You can find every (not item) name in the official trade site by changing your language in the right top and go to https://de.pathofexile.com/trade/about

For korean numbers I would suggest searching up the numbers https://en.wikipedia.org/wiki/Korean_numerals

Doing everything yourself would be a pain in the ass better filter through a HTTP request and the position where which name the item has for incoming whispers!

https://www.pathofexile.com/character-window/get-stash-items?accountName=stringName&tabIndex=stringName&league=stringName

krissrex commented 3 years ago

Looking at the poe api responses can give some clues.

Here is one in korean:

```json { "id": "55bdecf0bec0c8ace913089aa23cb39d21f3a3b4d71fe101600c0a7fd44410f0", "listing": { "method": "psapi", "indexed": "2021-05-04T16:35:35Z", "stash": { "name": "판매", "x": 1, "y": 4 }, "whisper": "@해그톡식 안녕하세요, 결전(보관함 탭 \"판매\", 위치: 왼쪽 2, 상단 5)에 7 exalted(으)로 올려놓은 레벨 5 23% 각성한 치명적인 상태 이상 보조(을)를 구매하고 싶습니다", "account": { "name": "chang_2", "lastCharacterName": "해그톡식", "online": null, "language": "ko_KR" }, "price": { "type": "~price", "amount": 7, "currency": "exalted" } }, "item": { "verified": true, "w": 1, "h": 1, "icon": "https://web.poecdn.com/image/Art/2DItems/Gems/Support/SupportPlus/DeadlyAilmentsPlus.png?v=270f401a324ca772e6e2d3c4abca8c1b&w=1&h=1&scale=1", "support": true, "league": "Ultimatum", "id": "55bdecf0bec0c8ace913089aa23cb39d21f3a3b4d71fe101600c0a7fd44410f0", "name": "", "typeLine": "Awakened Deadly Ailments Support", "baseType": "Awakened Deadly Ailments Support", "identified": true, "ilvl": 0, "note": "~price 7 exalted", "corrupted": true, "properties": [ { "name": "Support", "values": [], "displayMode": 0 }, { "name": "Level", "values": [ [ "5 (Max)", 0 ] ], "displayMode": 0, "type": 5 }, { "name": "Cost & Reservation Multiplier", "values": [ [ "130%", 0 ] ], "displayMode": 0 }, { "name": "Quality", "values": [ [ "+23%", 1 ] ], "displayMode": 0, "type": 6 } ], "requirements": [ { "name": "Level", "values": [ [ "80", 0 ] ], "displayMode": 0 }, { "name": "Dex", "values": [ [ "79", 0 ] ], "displayMode": 1 }, { "name": "Int", "values": [ [ "55", 0 ] ], "displayMode": 1 } ], "secDescrText": "Supports any skill that hits enemies.", "explicitMods": [ "Supported Skills deal 69% more Damage with Ailments", "Supported Skills deal 10% less Damage with Hits", "Supported Skills deal 11% increased Damage over Time", "Damaging Ailments inflicted with Supported Skills deal damage 12% faster" ], "descrText": "This is a Support Gem. It does not grant a bonus to your character, but to skills in sockets connected to it. Place into an item socket connected to a socket containing the Active Skill Gem you wish to augment. Right click to remove from a socket.", "frameType": 4, "extended": { "text": "SXRlbSBDbGFzczogU3VwcG9ydCBTa2lsbCBHZW1zDQpSYXJpdHk6IEdlbQ0KQXdha2VuZWQgRGVhZGx5IEFpbG1lbnRzIFN1cHBvcnQNCi0tLS0tLS0tDQpTdXBwb3J0DQpMZXZlbDogNSAoTWF4KQ0KQ29zdCAmIFJlc2VydmF0aW9uIE11bHRpcGxpZXI6IDEzMCUNClF1YWxpdHk6ICsyMyUgKGF1Z21lbnRlZCkNCi0tLS0tLS0tDQpSZXF1aXJlbWVudHM6DQpMZXZlbDogODANCkRleDogNzkNCkludDogNTUNCi0tLS0tLS0tDQpTdXBwb3J0cyBhbnkgc2tpbGwgdGhhdCBoaXRzIGVuZW1pZXMuDQotLS0tLS0tLQ0KU3VwcG9ydGVkIFNraWxscyBkZWFsIDY5JSBtb3JlIERhbWFnZSB3aXRoIEFpbG1lbnRzDQpTdXBwb3J0ZWQgU2tpbGxzIGRlYWwgMTAlIGxlc3MgRGFtYWdlIHdpdGggSGl0cw0KU3VwcG9ydGVkIFNraWxscyBkZWFsIDExJSBpbmNyZWFzZWQgRGFtYWdlIG92ZXIgVGltZQ0KRGFtYWdpbmcgQWlsbWVudHMgaW5mbGljdGVkIHdpdGggU3VwcG9ydGVkIFNraWxscyBkZWFsIGRhbWFnZSAxMiUgZmFzdGVyDQotLS0tLS0tLQ0KVGhpcyBpcyBhIFN1cHBvcnQgR2VtLiBJdCBkb2VzIG5vdCBncmFudCBhIGJvbnVzIHRvIHlvdXIgY2hhcmFjdGVyLCBidXQgdG8gc2tpbGxzIGluIHNvY2tldHMgY29ubmVjdGVkIHRvIGl0LiBQbGFjZSBpbnRvIGFuIGl0ZW0gc29ja2V0IGNvbm5lY3RlZCB0byBhIHNvY2tldCBjb250YWluaW5nIHRoZSBBY3RpdmUgU2tpbGwgR2VtIHlvdSB3aXNoIHRvIGF1Z21lbnQuIFJpZ2h0IGNsaWNrIHRvIHJlbW92ZSBmcm9tIGEgc29ja2V0Lg0KLS0tLS0tLS0NCkNvcnJ1cHRlZA0KLS0tLS0tLS0NCk5vdGU6IH5wcmljZSA3IGV4YWx0ZWQNCg==" } } } ```

You can see the whisper: @해그톡식 안녕하세요, 결전(보관함 탭 \"판매\", 위치: 왼쪽 2, 상단 5)에 7 exalted(으)로 올려놓은 레벨 5 23% 각성한 치명적인 상태 이상 보조(을)를 구매하고 싶습니다

and the json lets you find the stash tab name, which is 판매,
the stash x: 1 (shown as 2),
the stash y: 4 (shown as 5),
the price of 7 exalted,
the username 해그톡식.

What is missing is to find and translate the item names. At least 5 23% is part of it.
As an initial solution, one can display the foreign (Korean) item names, as long as the price and username is correct. If that is hard, maybe just display "unknown" or something like that.

krissrex commented 3 years ago

I created a junit test for different languages. It can be improved with more samples and languages. https://github.com/krissrex/MercuryTrade-Community-Fork/commit/6e9bb41982bcf07ce8fc29a48ef1bb365a22b96a It tests the TradeOutMessagesInterceptor.

krissrex commented 3 years ago

I did some work on the regex parsing. It should work for Russian and Korean. I need some more trade samples for Thai, but I rarely see Thai trades now anyways.

The item names are not translated yet. This means the notifications would show e.g. Korean names for items. But the player name and price is correct, so it should help enough for outgoing trades.

krissrex commented 3 years ago

It's possible but i don't have a template in these languages. And google translate dont work perfect with russian and korean

I got multiple different trades for the same language, and compared them to see what differed. It took some time, but it worked.

To find the league names, I used the flag-icon in the top right to visit different pathofexile.com trade sites, and copied the text from the league selection dropdown.

krissrex commented 3 years ago

Here are two Russian currency trades:

German item trades:

A Thai item trade:

A spanish item trade:

A french skill gem trade: