Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use alternative words in step written in Japanese? (no spaces between words) #175

Closed
hanachin opened this issue Feb 9, 2016 · 5 comments

Comments

@hanachin
Copy link
Contributor

hanachin commented Feb 9, 2016

I want to write the step like following:

step "〜の中に/の○○" do |innner_step|
  # 〜
end
# expect it matches "〜の中に○○" and "〜の中の○○" steps

but turnip compiles that to something like following regexp:

/(〜の中に|の)○○/

I know wrap alternative words with optional parts parences would work, but it match step without に/の.

step "〜の中(に/の)○○" do |innner_step|
  # 〜
end
# it matches the step like:
# 〜の中○○

Here is my work around:

step "〜の中( )に/の( )○○" do |innner_step|
end
# it matches "〜の中に○○" and "〜の中の○○" steps, also match "〜の中 に ○○", "〜の中 の ○○"
@gongo
Copy link
Collaborator

gongo commented Feb 9, 2016

Hi @hanachin

I know wrap alternative words with optional parts parences would work, but it match step without に/の.

step "〜の中(に/の)○○" do |innner_step|
  # 〜
end
# it matches the step like:
# 〜の中○○

Hmm.. it ran as expected when I try.
(sample codes: https://gist.github.com/gongo/00e21949dd62c591e45d)

@gongo
Copy link
Collaborator

gongo commented Feb 9, 2016

Oh.

# it matches the step like:
# 〜の中○○

means

    And ポケットの中の戦争      # <= match OK
    And ポケットの中にビスケット # <= match OK
    And ポケットの中ガンダム    # <= match but not expect

?

(Japanese!!)

すいません、 @hanachin さんが問題にしているのは、上の例で
1番目と2番目はともかく、3番目までマッチしてしまうのはよろしくないなーという意味でしたか?

@hanachin
Copy link
Contributor Author

hanachin commented Feb 9, 2016

@gongo はい。(慣れない英語で言葉たらずですみません)

@gongo
Copy link
Collaborator

gongo commented Feb 9, 2016

@hanachin

Umm... sorry, it is difficult to specify alternative words to text not leaving a space between words (= 分かち書き).

  • 〜の中に/の can be divided as follows:
    • 〜の中 に/の
    • 〜の 中に/の
    • の中に/の

turnip don't know the correct.

And, (に/の) syntax is recognized as optional parts https://github.com/jnicklas/turnip#placeholders

  • 〜の中の
  • 〜の中に
  • 〜の中

Correct all!


(Japanese!!)

なので、現状は workaround をそのまま続けていただくか、
助詞が無い場合もマッチしてしまう可能性は残っていますが
そこそこ見易い (の/に) という書き方でカバーしていただけますか。

@hanachin
Copy link
Contributor Author

hanachin commented Feb 9, 2016

thank you for quick response!

ありがとうございます 🍕

@hanachin hanachin closed this as completed Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants